diff --git a/package.json b/package.json index 36953fb..b03454e 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "rech-editor-cobol", "displayName": "Rech COBOL", "description": "Edit COBOL files with vscode.", - "version": "1.0.136", + "version": "1.0.138", "publisher": "rechinformatica", "engines": { "vscode": "^1.47.0" @@ -69,17 +69,17 @@ "description": "COBOL tabstops." }, "rech.editor.cobol.showConditionalBlockCobolFlow": { - "type": [ - "boolean", - "boolean" - ], - "enum": [ - false, - true - ], - "description": "Show conditional blocks on COBOL Flow Tree View.", - "default": true - }, + "type": [ + "boolean", + "boolean" + ], + "enum": [ + false, + true + ], + "description": "Show conditional blocks on COBOL Flow Tree View.", + "default": true + }, "rech.editor.cobol.formatter.location": { "type": "string", "description": "External COBOL formatter location." @@ -186,7 +186,7 @@ "path": "./syntaxes/COBOL.tmLanguage.json" } ], - "snippets": [ + "snippets": [ { "language": "COBOL", "path": "./snippets/cobol.json" @@ -349,6 +349,18 @@ { "command": "rech.editor.cobol.extractParagraph", "title": "Rech COBOL: Extract selected lines to a new paragraph" + }, + { + "command": "rech.editor.cobol.changeParagraphSource", + "title": "Rech COBOL: Muda fonte de análise do autocompletar para parágrafos" + }, + { + "command": "rech.editor.cobol.changeVariableSource", + "title": "Rech COBOL: Muda fonte de análise do autocompletar para variáveis" + }, + { + "command": "rech.editor.cobol.changeBothSourceOfCompletion", + "title": "Rech COBOL: Muda fonte de análise do autocompletar para parágrafos/variáveis" } ], "keybindings": [ @@ -461,6 +473,11 @@ "command": "rech.editor.cobol.showElementProperties", "key": "shift+alt+q", "when": "editorLangId == COBOL" + }, + { + "command": "rech.editor.cobol.changeBothSourceOfCompletion", + "key": "ctrl+alt+j", + "title": "Rech COBOL: Muda fonte de análise do autocompletar para parágrafos/variáveis" } ] }, diff --git a/src/extension.ts b/src/extension.ts index 8451a5f..7b490eb 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -143,6 +143,13 @@ async function _activate(context: any) { SourceOfCompletions.toggleTheVariableSource(document.fileName, context); } })); + context.subscriptions.push(commands.registerCommand('rech.editor.cobol.changeBothSourceOfCompletion', () => { + const activeEditor = window.activeTextEditor; + if (activeEditor) { + const document = activeEditor.document; + SourceOfCompletions.toggleBothSource(document.fileName, context); + } + })); context.subscriptions.push(commands.registerCommand('rech.editor.cobol.definesSourceExpander', () => { const activeEditor = window.activeTextEditor; if (activeEditor) { diff --git a/src/lsp/commons/SourceOfCompletions.ts b/src/lsp/commons/SourceOfCompletions.ts index 88d4690..3e0158f 100644 --- a/src/lsp/commons/SourceOfCompletions.ts +++ b/src/lsp/commons/SourceOfCompletions.ts @@ -105,6 +105,25 @@ export class SourceOfCompletions { } } + /** + * Toggles both paragraph and variable sources, ensuring they match and then inverting them. + * Paragraph will always toggle, and variable toggles only if it differs. + * + * @param fileName - The name of the file currently being edited. + * @param context - The extension context used to save the updated state. + */ + public static toggleBothSource(fileName: string, context: ExtensionContext) { + this.toggleTheParagraphSource(fileName, context); + + const paragraphSource = SourceOfCompletions.getSourceOfParagraphCompletions(fileName); + const variableSource = SourceOfCompletions.getSourceOfVariableCompletions(fileName); + + if (paragraphSource !== variableSource) { + this.toggleTheVariableSource(fileName, context); + } + } + + /** * Toggles the paragraph source between "local" and "expanded" for the given file. * @@ -128,10 +147,10 @@ export class SourceOfCompletions { * @param fileName - The name of the file currently being edited. * @param context - The extension context used to save the updated state. */ - public static toggleTheVariableSource(fileName: string, context: ExtensionContext) { - if (SourceOfCompletions.getSourceOfVariableCompletions(fileName) == SOURCE_LOCAL) { - SourceOfCompletions.variableSource.set(fileName, SOURCE_EXPANDED); - SourceOfCompletions.variableStatusBar!.text = VARIABLE_SOURCE_EXPANDED_FILE + public static toggleTheVariableSource(fileName: string, context: ExtensionContext) { + if (SourceOfCompletions.getSourceOfVariableCompletions(fileName) == SOURCE_LOCAL) { + SourceOfCompletions.variableSource.set(fileName, SOURCE_EXPANDED); + SourceOfCompletions.variableStatusBar!.text = VARIABLE_SOURCE_EXPANDED_FILE } else { SourceOfCompletions.variableSource.set(fileName, SOURCE_LOCAL); SourceOfCompletions.variableStatusBar!.text = VARIABLE_SOURCE_LOCAL_FILE @@ -159,7 +178,7 @@ export class SourceOfCompletions { * @param fileName - The name of the file for which to get the source. * @returns The source of variable completions ("local" or "expanded"). */ - public static getSourceOfVariableCompletions(fileName: string) { + public static getSourceOfVariableCompletions(fileName: string) { const config = SourceOfCompletions.variableSource.get(fileName); if (config) { return config