Restructure and rename settings

Co-authored-by: David Kincaid <daelonsuzuka@gmail.com>
This commit is contained in:
oidro
2023-03-26 16:32:36 -04:00
committed by GitHub
parent a561c523ee
commit cdc550a412
11 changed files with 169 additions and 104 deletions

View File

@@ -67,7 +67,7 @@ You can use the following settings to configure Godot Tools:
- `editor_path` - The absolute path to the Godot editor executable. _Under Mac OS, this is the executable inside of Godot.app._
- `gdscript_lsp_server_port` - The WebSocket server port of the GDScript language server.
- `check_status` - Check the GDScript language server connection status.
- `checkStatus` - Check the GDScript language server connection status.
#### GDScript Debugger

View File

@@ -46,27 +46,27 @@
"contributes": {
"commands": [
{
"command": "godot-tool.open_editor",
"command": "godotTools.openEditor",
"title": "Godot Tools: Open workspace with Godot editor"
},
{
"command": "godot-tool.run_project",
"command": "godotTools.runProject",
"title": "Godot Tools: Run workspace as Godot project"
},
{
"command": "godot-tool.run_project_debug",
"command": "godotTools.runProjectDebug",
"title": "Godot Tools: Run workspace as Godot project with visible collision shapes and navigation meshes"
},
{
"command": "godot-tool.list_native_classes",
"command": "godotTools.listNativeClasses",
"title": "Godot Tools: List native classes of godot"
},
{
"command": "godot-tool.open_type_documentation",
"command": "godotTools.openTypeDocumentation",
"title": "Godot Tools: Open Type Documentation"
},
{
"command": "godot-tool.debugger.inspect_node",
"command": "godotTools.debugger.inspectNode",
"title": "Inspect Remote Node",
"icon": {
"light": "resources/light/icon_GUI_visibility_visible.svg",
@@ -74,7 +74,7 @@
}
},
{
"command": "godot-tool.debugger.refresh_scene_tree",
"command": "godotTools.debugger.refreshSceneTree",
"title": "Refresh",
"icon": {
"light": "resources/light/icon_refresh.svg",
@@ -82,7 +82,7 @@
}
},
{
"command": "godot-tool.debugger.refresh_inspector",
"command": "godotTools.debugger.refreshInspector",
"title": "Refresh",
"icon": {
"light": "resources/light/icon_refresh.svg",
@@ -90,7 +90,7 @@
}
},
{
"command": "godot-tool.debugger.edit_value",
"command": "godotTools.debugger.editValue",
"title": "Edit value",
"icon": {
"light": "resources/light/icon_edit.svg",
@@ -136,15 +136,15 @@
"title": "Godot Tools: Switch Scene/Script"
},
{
"command": "godot-tool.set_scene_file",
"command": "godotTools.setSceneFile",
"title": "Set as Scene File"
},
{
"command": "godot-tool.copy_resource_path_context",
"command": "godotTools.copyResourcePathContext",
"title": "Copy Resource Path"
},
{
"command": "godot-tool.copy_resource_path",
"command": "godotTools.copyResourcePath",
"title": "Godot Tools: Copy Resource Path"
}
],
@@ -157,9 +157,9 @@
],
"configuration": {
"type": "object",
"title": "Godot Tools configuration",
"title": "Godot Tools",
"properties": {
"godot_tools.gdscript_lsp_server_protocol": {
"godotTools.lsp.serverProtocol": {
"type": [
"string"
],
@@ -169,57 +169,57 @@
],
"default": "tcp",
"enumDescriptions": [
"Using WebSocket protocol to connect to Godot 3.2 and Godot 3.2.1",
"Using TCP protocol to connect to Godot 3.2.2 and newer versions"
"Use the WebSocket protocol to connect to Godot 3.2 and Godot 3.2.1",
"Use the TCP protocol to connect to Godot 3.2.2 and newer versions"
],
"description": "The server protocol of the GDScript language server.\nYou have restart VSCode editor after change this value."
"description": "The server protocol of the GDScript language server.\nYou must restart VSCode after changing this value."
},
"godot_tools.gdscript_lsp_server_host": {
"godotTools.lsp.serverHost": {
"type": "string",
"default": "127.0.0.1",
"description": "The server host of the GDScript language server"
},
"godot_tools.gdscript_lsp_server_port": {
"godotTools.lsp.serverPort": {
"type": "number",
"default": 6008,
"description": "The server port of the GDScript language server"
},
"godot_tools.editor_path": {
"godotTools.editorPath": {
"type": "string",
"default": "",
"description": "The absolute path to the Godot editor executable"
},
"godot_tools.scene_file_config": {
"godotTools.sceneFileConfig": {
"type": "string",
"default": "",
"description": "The scene file to run"
},
"godot_tools.reconnect_automatically": {
"godotTools.lsp.autoReconnect.enabled": {
"type": "boolean",
"default": true,
"description": "Whether the plugin should attempt to reconnect"
"description": "Whether the plugin should attempt to reconnect to the GDScript language server"
},
"godot_tools.reconnect_cooldown": {
"godotTools.lsp.autoReconnect.cooldown": {
"type": "number",
"default": 3000,
"description": "The number of milliseconds to wait before attempting to reconnect"
},
"godot_tools.reconnect_attempts": {
"godotTools.lsp.autoReconnect.attempts": {
"type": "number",
"default": 10,
"description": "How many times the client will attempt to reconnect"
},
"godot_tools.force_visible_collision_shapes": {
"godotTools.forceVisibleCollisionShapes": {
"type": "boolean",
"default": false,
"description": "Force the project to run with visible collision shapes"
},
"godot_tools.force_visible_nav_mesh": {
"godotTools.forceVisibleNavMesh": {
"type": "boolean",
"default": false,
"description": "Force the project to run with visible navigation meshes"
},
"godot_tools.native_symbol_placement": {
"godotTools.nativeSymbolPlacement": {
"enum": [
"active",
"beside"
@@ -231,7 +231,7 @@
"default": "beside",
"description": "Where to place the native symbol windows"
},
"godot_tools.scenePreview.previewRelatedScenes": {
"godotTools.scenePreview.previewRelatedScenes": {
"enum": [
"anyFolder",
"sameFolder",
@@ -353,10 +353,10 @@
"description": "Relative path from the godot.project file to a TSCN file. If launch_scene and launch_game_instance are true, and this file is defined, will launch the specified file instead of looking for an active TSCN file.",
"default": ""
},
"additional_options":{
"type":"string",
"additional_options": {
"type": "string",
"description": "Additional command line arguments.",
"default":""
"default": ""
}
}
}
@@ -371,7 +371,7 @@
"address": "127.0.0.1",
"launch_game_instance": true,
"launch_scene": false,
"additional_options":""
"additional_options": ""
}
],
"configurationSnippets": [
@@ -386,7 +386,7 @@
"address": "127.0.0.1",
"launch_game_instance": true,
"launch_scene": false,
"additional_options":""
"additional_options": ""
}
}
]
@@ -461,18 +461,18 @@
"when": "false"
},
{
"command": "godot-tool.copy_resource_path_context",
"command": "godotTools.copyResourcePathContext",
"when": "false"
}
],
"view/title": [
{
"command": "godot-tool.debugger.refresh_scene_tree",
"command": "godotTools.debugger.refreshSceneTree",
"when": "view == active-scene-tree",
"group": "navigation"
},
{
"command": "godot-tool.debugger.refresh_inspector",
"command": "godotTools.debugger.refreshInspector",
"when": "view == inspect-node",
"group": "navigation"
},
@@ -489,17 +489,17 @@
],
"view/item/context": [
{
"command": "godot-tool.debugger.inspect_node",
"command": "godotTools.debugger.inspectNode",
"when": "view == active-scene-tree",
"group": "inline"
},
{
"command": "godot-tool.debugger.inspect_node",
"command": "godotTools.debugger.inspectNode",
"when": "view == inspect-node && viewItem == remote_object",
"group": "inline"
},
{
"command": "godot-tool.debugger.edit_value",
"command": "godotTools.debugger.editValue",
"when": "view == inspect-node && viewItem == editable_value",
"group": "inline"
},
@@ -529,23 +529,23 @@
],
"explorer/context": [
{
"command": "godot-tool.set_scene_file",
"command": "godotTools.setSceneFile",
"group": "2_workspace"
},
{
"command": "godot-tool.copy_resource_path_context",
"command": "godotTools.copyResourcePathContext",
"group": "6_copypath"
}
],
"editor/title/context": [
{
"command": "godot-tool.copy_resource_path_context",
"command": "godotTools.copyResourcePathContext",
"group": "1_godot"
}
],
"editor/context": [
{
"command": "godot-tool.open_type_documentation",
"command": "godotTools.openTypeDocumentation",
"when": "godotTools.context.connectedToEditor",
"group": "navigation@9"
},

View File

@@ -1,19 +1,15 @@
import {
LoggingDebugSession,
InitializedEvent,
Thread,
Source,
Breakpoint,
Breakpoint, InitializedEvent, LoggingDebugSession, Source, Thread
} from "vscode-debugadapter";
import { DebugProtocol } from "vscode-debugprotocol";
import { Mediator } from "./mediator";
import { get_configuration } from "../utils";
import { GodotDebugData, GodotVariable } from "./debug_runtime";
import { ObjectId, RawObject } from "./variables/variants";
import { Mediator } from "./mediator";
import { SceneTreeProvider } from "./scene_tree/scene_tree_provider";
import { ServerController } from "./server_controller";
import { ObjectId, RawObject } from "./variables/variants";
const { Subject } = require("await-notify");
import fs = require("fs");
import { SceneTreeProvider } from "./scene_tree/scene_tree_provider";
import { get_configuration } from "../utils";
interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArguments {
address: string;
@@ -238,7 +234,7 @@ export class GodotDebugSession extends LoggingDebugSession {
args.launch_scene,
args.scene_file,
args.additional_options,
get_configuration("scene_file_config", "") || args.scene_file,
get_configuration("sceneFileConfig", "") || args.scene_file,
]);
this.sendResponse(response);

View File

@@ -40,7 +40,7 @@ export function register_debugger(context: ExtensionContext) {
);
commands.registerCommand(
"godot-tool.debugger.inspect_node",
"godotTools.debugger.inspectNode",
(element: SceneNode | RemoteProperty) => {
if (element instanceof SceneNode) {
Mediator.notify("inspect_object", [
@@ -70,11 +70,11 @@ export function register_debugger(context: ExtensionContext) {
}
);
commands.registerCommand("godot-tool.debugger.refresh_scene_tree", () => {
commands.registerCommand("godotTools.debugger.refreshSceneTree", () => {
Mediator.notify("request_scene_tree", []);
});
commands.registerCommand("godot-tool.debugger.refresh_inspector", () => {
commands.registerCommand("godotTools.debugger.refreshInspector", () => {
if (inspector_provider.has_tree()) {
let name = inspector_provider.get_top_name();
let id = inspector_provider.get_top_id();
@@ -88,7 +88,7 @@ export function register_debugger(context: ExtensionContext) {
});
commands.registerCommand(
"godot-tool.debugger.edit_value",
"godotTools.debugger.editValue",
(property: RemoteProperty) => {
let previous_value = property.value;
let type = typeof previous_value;

View File

@@ -98,9 +98,9 @@ export class ServerController {
this.debug_data = debug_data;
if (launch_instance) {
let godot_path: string = utils.get_configuration("editor_path", "godot");
const force_visible_collision_shapes = utils.get_configuration("force_visible_collision_shapes", false);
const force_visible_nav_mesh = utils.get_configuration("force_visible_nav_mesh", false);
let godot_path: string = utils.get_configuration("editorPath", "godot");
const force_visible_collision_shapes = utils.get_configuration("forceVisibleCollisionShapes", false);
const force_visible_nav_mesh = utils.get_configuration("forceVisibleNavMesh", false);
let executable_line = `"${godot_path}" --path "${project_path}" --remote-debug ${address}:${port}`;

View File

@@ -1,10 +1,16 @@
import { ExtensionContext } from "vscode";
import { GodotTools } from "./godot-tools";
import { shouldUpdateSettings, updateOldStyleSettings, updateStoredVersion } from "./settings_updater";
import debuggerContext = require("./debugger/debugger_context");
let tools: GodotTools = null;
export function activate(context: ExtensionContext) {
if (shouldUpdateSettings(context)) {
updateOldStyleSettings();
}
updateStoredVersion(context);
tools = new GodotTools(context);
tools.activate();
debuggerContext.register_debugger(context);

View File

@@ -1,12 +1,11 @@
import * as vscode from "vscode";
import * as path from "path";
import * as fs from "fs";
import * as path from "path";
import * as vscode from "vscode";
import { GDDocumentLinkProvider } from "./document_link_provider";
import { ScenePreviewProvider } from "./scene_preview_provider";
import GDScriptLanguageClient, { ClientStatus } from "./lsp/GDScriptLanguageClient";
import { ScenePreviewProvider } from "./scene_preview_provider";
import { get_configuration, set_configuration, find_file, set_context, find_project_file } from "./utils";
const CONFIG_CONTAINER = "godot_tools";
const TOOL_NAME = "GodotTools";
export class GodotTools {
@@ -28,24 +27,24 @@ export class GodotTools {
setInterval(() => {
this.retry_callback();
}, get_configuration("reconnect_cooldown", 3000));
}, get_configuration("lsp.autoReconnect.cooldown", 3000));
}
public activate() {
vscode.commands.registerCommand("godot-tool.open_editor", () => {
vscode.commands.registerCommand("godotTools.openEditor", () => {
this.open_workspace_with_editor("-e").catch(err => vscode.window.showErrorMessage(err));
});
vscode.commands.registerCommand("godot-tool.run_project", () => {
vscode.commands.registerCommand("godotTools.runProject", () => {
this.open_workspace_with_editor().catch(err => vscode.window.showErrorMessage(err));
});
vscode.commands.registerCommand("godot-tool.run_project_debug", () => {
vscode.commands.registerCommand("godotTools.runProjectDebug", () => {
this.open_workspace_with_editor("--debug-collisions --debug-navigation").catch(err => vscode.window.showErrorMessage(err));
});
vscode.commands.registerCommand("godot-tool.check_status", this.check_client_status.bind(this));
vscode.commands.registerCommand("godot-tool.set_scene_file", this.set_scene_file.bind(this));
vscode.commands.registerCommand("godot-tool.copy_resource_path_context", this.copy_resource_path.bind(this));
vscode.commands.registerCommand("godot-tool.copy_resource_path", this.copy_resource_path.bind(this));
vscode.commands.registerCommand("godot-tool.open_type_documentation", this.open_type_documentation.bind(this));
vscode.commands.registerCommand("godotTools.checkStatus", this.check_client_status.bind(this));
vscode.commands.registerCommand("godotTools.setSceneFile", this.set_scene_file.bind(this));
vscode.commands.registerCommand("godotTools.copyResourcePathContext", this.copy_resource_path.bind(this));
vscode.commands.registerCommand("godotTools.copyResourcePath", this.copy_resource_path.bind(this));
vscode.commands.registerCommand("godotTools.openTypeDocumentation", this.open_type_documentation.bind(this));
vscode.commands.registerCommand("godotTools.switchSceneScript", this.switch_scene_script.bind(this));
set_context("godotTools.context.connectedToEditor", false);
@@ -53,7 +52,7 @@ export class GodotTools {
this.scenePreviewManager = new ScenePreviewProvider();
this.connection_status.text = "$(sync) Initializing";
this.connection_status.command = "godot-tool.check_status";
this.connection_status.command = "godotTools.checkStatus";
this.connection_status.show();
this.reconnection_attempts = 0;
@@ -134,7 +133,7 @@ export class GodotTools {
private set_scene_file(uri: vscode.Uri) {
let right_clicked_scene_path = uri.fsPath;
let scene_config = get_configuration("scene_file_config");
let scene_config = get_configuration("sceneFileConfig");
if (scene_config == right_clicked_scene_path) {
scene_config = "";
}
@@ -142,7 +141,7 @@ export class GodotTools {
scene_config = right_clicked_scene_path;
}
set_configuration("scene_file_config", scene_config);
set_configuration("sceneFileConfig", scene_config);
}
private run_editor(params = "") {
@@ -207,7 +206,7 @@ export class GodotTools {
resolve();
};
let editorPath = get_configuration("editor_path", "");
let editorPath = get_configuration("editorPath", "");
if (!fs.existsSync(editorPath) || !fs.statSync(editorPath).isFile()) {
vscode.window.showOpenDialog({
openLabel: "Run",
@@ -221,7 +220,7 @@ export class GodotTools {
reject("Invalid editor path to run the project");
} else {
run_godot(path, params);
set_configuration("editor_path", path);
set_configuration("editorPath", path);
}
});
} else {
@@ -231,8 +230,8 @@ export class GodotTools {
}
private check_client_status() {
let host = get_configuration("gdscript_lsp_server_host", "localhost");
let port = get_configuration("gdscript_lsp_server_port", 6008);
let host = get_configuration("lsp.serverPort", "localhost");
let port = get_configuration("lsp.serverHost", 6008);
switch (this.client.status) {
case ClientStatus.PENDING:
vscode.window.showInformationMessage(`Connecting to the GDScript language server at ${host}:${port}`);
@@ -247,8 +246,8 @@ export class GodotTools {
}
private on_client_status_changed(status: ClientStatus) {
let host = get_configuration("gdscript_lsp_server_host", "localhost");
let port = get_configuration("gdscript_lsp_server_port", 6008);
let host = get_configuration("lsp.serverHost", "localhost");
let port = get_configuration("lsp.serverPort", 6008);
switch (status) {
case ClientStatus.PENDING:
this.connection_status.text = `$(sync) Connecting`;
@@ -288,8 +287,8 @@ export class GodotTools {
}
private retry_connect_client() {
const auto_retry = get_configuration("reconnect_automatically", true);
const max_attempts = get_configuration("reconnect_attempts", 10);
const auto_retry = get_configuration("lsp.autoReconnect.enabled", true);
const max_attempts = get_configuration("lsp.autoReconnect.attempts", 10);
if (auto_retry && this.reconnection_attempts <= max_attempts) {
this.reconnection_attempts++;
this.client.connect_to_server();
@@ -302,8 +301,8 @@ export class GodotTools {
this.connection_status.text = `$(x) Disconnected`;
this.connection_status.tooltip = `Disconnected from the GDScript language server.`;
let host = get_configuration("gdscript_lsp_server_host", "localhost");
let port = get_configuration("gdscript_lsp_server_port", 6008);
let host = get_configuration("lsp.ServerHost", "localhost");
let port = get_configuration("lsp.ServerPort", 6008);
let message = `Couldn't connect to the GDScript language server at ${host}:${port}. Is the Godot editor running?`;
vscode.window.showErrorMessage(message, "Open Godot Editor", "Retry", "Ignore").then(item => {
if (item == "Retry") {

View File

@@ -1,9 +1,9 @@
import * as vscode from 'vscode';
import { LanguageClient, LanguageClientOptions, ServerOptions, RequestMessage } from "vscode-languageclient/node";
import { is_debug_mode, get_configuration } from "../utils";
import { MessageIO, MessageIOReader, MessageIOWriter, Message, WebSocketMessageIO, TCPMessageIO } from "./MessageIO";
import logger from "../logger";
import { EventEmitter } from "events";
import * as vscode from 'vscode';
import { LanguageClient, RequestMessage } from "vscode-languageclient/node";
import logger from "../logger";
import { get_configuration, is_debug_mode } from "../utils";
import { Message, MessageIO, MessageIOReader, MessageIOWriter, TCPMessageIO, WebSocketMessageIO } from "./MessageIO";
import NativeDocumentManager from './NativeDocumentManager';
export enum ClientStatus {
@@ -15,7 +15,7 @@ const CUSTOM_MESSAGE = "gdscrip_client/";
export default class GDScriptLanguageClient extends LanguageClient {
public readonly io: MessageIO = (get_configuration("gdscript_lsp_server_protocol", "tcp") == "ws") ? new WebSocketMessageIO() : new TCPMessageIO();
public readonly io: MessageIO = (get_configuration("lsp.serverProtocol", "tcp") == "ws") ? new WebSocketMessageIO() : new TCPMessageIO();
private context: vscode.ExtensionContext;
private _started : boolean = false;
@@ -78,8 +78,8 @@ export default class GDScriptLanguageClient extends LanguageClient {
connect_to_server() {
this.status = ClientStatus.PENDING;
let host = get_configuration("gdscript_lsp_server_host", "127.0.0.1");
let port = get_configuration("gdscript_lsp_server_port", 6008);
let host = get_configuration("lsp.serverHost", "127.0.0.1");
let port = get_configuration("lsp.serverPort", 6008);
this.io.connect_to_language_server(host, port);
}
@@ -113,7 +113,7 @@ export default class GDScriptLanguageClient extends LanguageClient {
message["result"][i]["target"] = x.replace('file://', 'file:///');
}
}
this.message_handler.on_message(message);
}

View File

@@ -22,7 +22,6 @@ marked.setOptions({
const enum WebViewMessageType {
INSPECT_NATIVE_SYMBOL = "INSPECT_NATIVE_SYMBOL",
}
const LIST_NATIVE_CLASS_COMMAND = "godot-tool.list_native_classes";
export default class NativeDocumentManager extends EventEmitter {
private io: MessageIO = null;
@@ -54,7 +53,7 @@ export default class NativeDocumentManager extends EventEmitter {
});
vscode.commands.registerCommand(
LIST_NATIVE_CLASS_COMMAND,
"godotTools.listNativeClasses",
this.list_native_classes.bind(this)
);
}
@@ -86,7 +85,7 @@ export default class NativeDocumentManager extends EventEmitter {
private inspect_native_symbol(params: NativeSymbolInspectParams) {
let json_data = "";
if (get_configuration("gdscript_lsp_server_protocol", "tcp") == "ws") {
if (get_configuration("lsp.serverProtocol", "tcp") == "ws") {
json_data = JSON.stringify({
id: -1,
jsonrpc: "2.0",
@@ -130,7 +129,7 @@ export default class NativeDocumentManager extends EventEmitter {
* configuration and previously opened native symbols.
*/
private get_new_native_symbol_column(): vscode.ViewColumn {
const config_placement = get_configuration("native_symbol_placement", "beside");
const config_placement = get_configuration("nativeSymbolPlacement", "beside");
if (config_placement == "active") {
return vscode.ViewColumn.Active;
@@ -148,7 +147,7 @@ export default class NativeDocumentManager extends EventEmitter {
if (is_non_editor_column_active) {
return active_column;
}
const all_columns = tab_groups.all.map(group => group.viewColumn);
const first_non_editor_column = all_columns.find(column => !editor_columns.includes(column));
if (first_non_editor_column) {

61
src/settings_updater.ts Normal file
View File

@@ -0,0 +1,61 @@
import * as vscode from "vscode";
const OLD_SETTINGS_CONVERSIONS = [
["godot_tools.gdscript_lsp_server_protocol", "godotTools.lsp.serverProtocol"],
["godot_tools.gdscript_lsp_server_host", "godotTools.lsp.serverHost"],
["godot_tools.gdscript_lsp_server_port", "godotTools.lsp.serverPort"],
["godot_tools.editor_path", "godotTools.editorPath"],
["godot_tools.scene_file_config", "godotTools.sceneFileConfig"],
["godot_tools.reconnect_automatically", "godotTools.lsp.autoReconnect.enabled"],
["godot_tools.reconnect_cooldown", "godotTools.lsp.autoReconnect.cooldown"],
["godot_tools.reconnect_attempts", "godotTools.lsp.autoReconnect.attempts"],
["godot_tools.force_visible_collision_shapes", "godotTools.forceVisibleCollisionShapes"],
["godot_tools.force_visible_nav_mesh", "godotTools.forceVisibleNavMesh"],
["godot_tools.native_symbol_placement", "godotTooPtabls.nativeSymbolPlacement"],
["godot_tools.scenePreview.previewRelatedScenes", "godotTools.scenePreview.previewRelatedScenes"]
];
export function updateOldStyleSettings() {
let configuration = vscode.workspace.getConfiguration();
let settings_changed = false;
for (let [old_style_key, new_style_key] of OLD_SETTINGS_CONVERSIONS) {
let value = configuration.get(old_style_key);
if (value === undefined) {
continue;
}
configuration.update(old_style_key, undefined, true);
configuration.update(new_style_key, value, true);
settings_changed = true;
}
if (settings_changed) {
// Only show this message if things have actually changed, to prevent users who
// are just reinstalling the extension from receiveing it.
vscode.window.showInformationMessage(
`Settings from godot-tools version <1.4.0 have been updated to the new format.
Please view the changelog for version 1.4.0 for more information.`,
'Okay'
);
}
}
/**
* Stores the current version of the extension to `context.globalState`,
* which persists across restarts & updates.
*/
export function updateStoredVersion(context: vscode.ExtensionContext) {
const syncedVersion: string = vscode.extensions.getExtension(context.extension.id)!
.packageJSON.version;
context.globalState.update("previousVersion", syncedVersion);
}
/**
* Checks if settings should try and be converted from the <1.4.0 style.
*
* Returns `true` if the extension has no value saved for `localVersion`
* in `context.globalState`, meaning it was either just installed,
* or updated from a version <1.4.0. Otherwise, returns `false`.
*/
export function shouldUpdateSettings(context: vscode.ExtensionContext) : boolean {
const localVersion: string | undefined = context.globalState.get("previousVersion");
return localVersion === undefined;
}

View File

@@ -2,10 +2,14 @@ import * as vscode from "vscode";
import * as path from "path";
import * as fs from "fs";
const CONFIG_CONTAINER = "godot_tools";
const CONFIG_CONTAINER = "godot-tools";
export function get_configuration(name: string, default_value: any = null) {
return vscode.workspace.getConfiguration(CONFIG_CONTAINER).get(name, default_value) || default_value;
let config_value = vscode.workspace.getConfiguration(CONFIG_CONTAINER).get(name, null);
if (config_value === null) {
return default_value;
}
return config_value;
}
export function set_configuration(name: string, value: any) {