From a2e0927c648d4ea37117bb20b33413dacc07434c Mon Sep 17 00:00:00 2001 From: Oleg Shilo Date: Mon, 8 Apr 2024 21:46:42 +1000 Subject: [PATCH] Release v1.23.0 - Issue #94: Default class/function display settings --- CHANGELOG.md | 4 ++++ package.json | 2 +- src/tree_view.ts | 26 ++++++++++++++++++++++-- src/utils.ts | 53 +++++++++++++++++++++++++++++++++++++++--------- 4 files changed, 72 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23883a2..ba4ccf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 1.23.0 (8 April 2024) + +- Issue #94: Default class/function display settings + ## 1.22.0 (13 March 2024) - Added support for React modules in TypeScript and JavaScript syntax (*.tsx/*.jsx files). diff --git a/package.json b/package.json index b3e4c8e..b4236f1 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "codemap", "displayName": "CodeMap", "description": "Interactive code map for quick visualization and navigation within code DOM objects (e.g. classes, members).", - "version": "1.22.0", + "version": "1.23.0", "license": "MIT", "publisher": "oleg-shilo", "engines": { diff --git a/src/tree_view.ts b/src/tree_view.ts index 04c36ce..e538d17 100644 --- a/src/tree_view.ts +++ b/src/tree_view.ts @@ -1,6 +1,7 @@ import * as vscode from 'vscode'; import * as path from 'path'; -import { Config, config_defaults } from './utils'; +import * as fs from 'fs'; +import { Config, Utils, config_defaults } from './utils'; const defaults = new config_defaults(); @@ -37,6 +38,12 @@ export class SettingsTreeProvider implements vscode.TreeDataProvider MapInfo) { this._settings = {}; + + var state = Config.getLastSessionState(); + if (state != null) { + this._settings = state; + } + vscode.window.onDidChangeActiveTextEditor(e => { this._onDidChangeTreeData.fire(null); }); @@ -139,11 +146,26 @@ export class SettingsTreeProvider implements vscode.TreeDataProvider { + if (err) { + console.error(err); + } + }); } } export class Utils { + public static read_all_text(file: string): string { + let text = fs.readFileSync(file, 'utf8'); + return text; + } + + public static write_all_text(file: string, text: string): void { + fs.writeFileSync(file, text, { encoding: 'utf8' }); + } + public static read_all_lines(file: string): string[] { let text = fs.readFileSync(file, 'utf8'); return text.split(/\r?\n/g); @@ -168,14 +195,20 @@ export class Utils { // Mac $HOME/Library/Application Support/Code/User/settings.json // Linux $HOME/.config/Code/User/settings.json - if (os.platform() == 'win32') { - process.env.VSCODE_USER = path.join(process.env.APPDATA, 'Code', 'User'); - } - else if (os.platform() == 'darwin') { - process.env.VSCODE_USER = path.join(process.env.HOME, 'Library', 'Application Support', 'Code', 'User'); - } - else { - process.env.VSCODE_USER = path.join(process.env.HOME, '.config', 'Code', 'User'); + /////////////////////////////////////// + let dataRoot = path.join(path.dirname(process.execPath), "data"); + let isPortable = (fs.existsSync(dataRoot) && fs.lstatSync(dataRoot).isDirectory()); + /////////////////////////////////////// + + if (isPortable) { + process.env.VSCODE_USER = path.join(dataRoot, 'user-data', 'User', 'globalStorage'); + } else { + if (os.platform() == 'win32') + process.env.VSCODE_USER = path.join(process.env.APPDATA, 'Code', 'User'); + else if (os.platform() == 'darwin') + process.env.VSCODE_USER = path.join(process.env.HOME, 'Library', 'Application Support', 'Code', 'User'); + else + process.env.VSCODE_USER = path.join(process.env.HOME, '.config', 'Code', 'User'); } } } \ No newline at end of file