Skip to content

Commit 11812f9

Browse files
Make init extension command use current file
This patch makes `init the exstension` command use the current file to determine the matching root folder. For instance you have this hierarchy. ``` workspace - proj1 - proj2 - file.txt ``` Previously the extension only created the LSP configuration file in `proj1` dir. Now if you open `file.txt` in `proj2` and run `init the extension`, it will create the configuration file in `proj2` dir.
1 parent be0c1bc commit 11812f9

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2222
- Now the id is `tarantool` instead of `tarantool-vscode` and the package name
2323
is simple `Tarantool`.
2424
- Tarantool annotations aren't longer used as a submodule.
25+
- Now initialize the extension command also tries to initialize the extension
26+
in the workspace folder in which the opened file is located.
2527

2628
### Fixed
2729

src/extension.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,18 @@ const emmyrc = {
1313
};
1414

1515
async function initVs() {
16+
const file = vscode.window.activeTextEditor?.document.uri.fsPath;
17+
1618
const wsedit = new vscode.WorkspaceEdit();
17-
const wsPath = vscode.workspace.workspaceFolders?.at(0)?.uri.fsPath;
19+
const wsFolders = vscode.workspace.workspaceFolders?.map((folder) => folder.uri.fsPath);
20+
if (!wsFolders) {
21+
vscode.window.showWarningMessage('Please, open a project before running this command');
22+
return;
23+
}
24+
25+
const wsPath = file ? wsFolders.find((folder) => file.startsWith(folder)) : wsFolders.at(0);
1826
if (!wsPath) {
19-
vscode.window.showWarningMessage('Please, open project before running this command');
27+
vscode.window.showWarningMessage('Please, open at least one folder within the workspace');
2028
return;
2129
}
2230

0 commit comments

Comments
 (0)