From 655d7c4aff00fc049a02c7c41fa7ed54e5076780 Mon Sep 17 00:00:00 2001 From: vinzbarbuto Date: Thu, 17 Oct 2024 10:42:45 -0700 Subject: [PATCH 1/2] Resolve goToLingoToml for Windows --- package.json | 5 ----- src/extension.ts | 2 -- src/lfview/lf-data-provider-commands.ts | 12 ------------ src/lfview/lf-data-provider.ts | 4 ++-- 4 files changed, 2 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index 0d1270235..56a76f957 100644 --- a/package.json +++ b/package.json @@ -223,11 +223,6 @@ "group": "inline@1", "when": "viewItem == project" }, - { - "command": "linguafranca.includeProject", - "group": "inline@1", - "when": "viewItem == root || viewItem == file-local" - }, { "command": "linguafranca.goToFile", "group": "inline@2", diff --git a/src/extension.ts b/src/extension.ts index 15c1e4d23..3387285c5 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -16,7 +16,6 @@ import { registerCollapseAllCommand, registerGoToFileCommand, registerGoToLingoTomlCommand, registerImportReactorCommand, - registerIncludeProjectCommand, registerOpenFolderCommand, registerOpenInSplitViewCommand, registerOpenInTerminalCommand, @@ -98,7 +97,6 @@ export async function activate(context: vscode.ExtensionContext) { registerImportReactorCommand(context, lfDataProvider); registerCollapseAllCommand(context); registerGoToLingoTomlCommand(context, lfDataProvider); - registerIncludeProjectCommand(context, lfDataProvider); registerOpenInTerminalCommand(context); registerOpenFolderCommand(context); diff --git a/src/lfview/lf-data-provider-commands.ts b/src/lfview/lf-data-provider-commands.ts index 9f4805d4e..117089ebf 100644 --- a/src/lfview/lf-data-provider-commands.ts +++ b/src/lfview/lf-data-provider-commands.ts @@ -79,18 +79,6 @@ export function registerGoToLingoTomlCommand(context: vscode.ExtensionContext, p )); } -export function registerIncludeProjectCommand(context: vscode.ExtensionContext, provider: LFDataProvider) { - context.subscriptions.push(vscode.commands.registerCommand( - 'linguafranca.includeProject', (node: LFDataProviderNode) => { - vscode.window.showInformationMessage('The "Include Project" feature is not implemented yet.', 'Details').then(selection => { - if (selection === "Details") { - vscode.window.showInformationMessage('Please use the Lingo command line to include the selected library in your current project. Once included, the library will appear under the "Lingo Packages" section.'); - } - }); - } - )); -} - export function registerOpenInTerminalCommand(context: vscode.ExtensionContext) { context.subscriptions.push(vscode.commands.registerCommand( 'linguafranca.openInTerminal', (node: LFDataProviderNode) => { diff --git a/src/lfview/lf-data-provider.ts b/src/lfview/lf-data-provider.ts index 75cedabc9..ec8096e98 100644 --- a/src/lfview/lf-data-provider.ts +++ b/src/lfview/lf-data-provider.ts @@ -796,7 +796,7 @@ export class LFDataProvider implements vscode.TreeDataProvider { From 94f2521d1501fe9bafb802c490dda2a106640840 Mon Sep 17 00:00:00 2001 From: vinzbarbuto Date: Thu, 17 Oct 2024 11:30:28 -0700 Subject: [PATCH 2/2] Fix bug and clean up code in ImportReactor command --- src/lfview/lf-data-provider-commands.ts | 14 ++++++--- src/lfview/lf-data-provider.ts | 38 +++++++++++-------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/lfview/lf-data-provider-commands.ts b/src/lfview/lf-data-provider-commands.ts index 117089ebf..49bf519d7 100644 --- a/src/lfview/lf-data-provider-commands.ts +++ b/src/lfview/lf-data-provider-commands.ts @@ -49,11 +49,17 @@ export function registerOpenInSplitViewCommand(context: vscode.ExtensionContext, export function registerImportReactorCommand(context: vscode.ExtensionContext, provider: LFDataProvider) { context.subscriptions.push(vscode.commands.registerCommand( 'linguafranca.importReactor', async (node: LFDataProviderNode) => { - if(node.type === LFDataProviderNodeType.LOCAL) { - await provider.importReactorCommand(node); + const editor = vscode.window.activeTextEditor; + + if (!editor) { + vscode.window.showErrorMessage('No active editor found.'); + return; } - else { - await provider.importLibraryReactorCommand(node); + + if (node.type === LFDataProviderNodeType.LOCAL) { + await provider.importReactorCommand(node, editor); + } else { + await provider.importLibraryReactorCommand(node, editor); } } )); diff --git a/src/lfview/lf-data-provider.ts b/src/lfview/lf-data-provider.ts index ec8096e98..45244bff4 100644 --- a/src/lfview/lf-data-provider.ts +++ b/src/lfview/lf-data-provider.ts @@ -674,18 +674,15 @@ export class LFDataProvider implements vscode.TreeDataProvider { + if (!editor.document.uri.path.endsWith('.lf')) { + vscode.window.showErrorMessage('The active editor must be a Ligua Franca program.'); + return; } + const relativePath = this.getRelativePath(editor.document.uri.path, node.uri.path); + const importText = `import ${node.label!.toString()} from "${relativePath}"\n`; + const position = await this.getTargetPosition(editor.document.uri); + this.addTextOnActiveEditor(editor, position!.end, importText); } /** @@ -695,18 +692,15 @@ export class LFDataProvider implements vscode.TreeDataProvider\n`; - const position = await this.getTargetPosition(editor.document.uri); - this.addTextOnActiveEditor(editor, position!.end, importText); + async importLibraryReactorCommand(node: LFDataProviderNode, editor: vscode.TextEditor): Promise { + if (!editor.document.uri.fsPath.endsWith('.lf')) { + vscode.window.showErrorMessage('The active editor must be a Ligua Franca program.'); + return; } + const relativePath = this.getLibraryPath(node.uri.path); + const importText = `import ${node.label!.toString()} from <${relativePath}>\n`; + const position = await this.getTargetPosition(editor.document.uri); + this.addTextOnActiveEditor(editor, position!.end, importText); } /**