From b31431096833ddc2eade3810fad752ca6483b0e8 Mon Sep 17 00:00:00 2001 From: Alessandro Fragnani Date: Tue, 9 Feb 2021 21:11:19 -0300 Subject: [PATCH] Add workspace/controller picker for clear --- src/extension.ts | 32 ++++++++++++++++---------------- vscode-numbered-bookmarks-core | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 4416151..65b50ea 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -133,8 +133,14 @@ export async function activate(context: vscode.ExtensionContext) { updateDecorations(); }); - vscode.commands.registerCommand("numberedBookmarks.clearFromAllFiles", () => { - for (const file of activeController.files) { + vscode.commands.registerCommand("numberedBookmarks.clearFromAllFiles", async () => { + + const controller = await pickController(controllers, activeController); + if (!controller) { + return + } + + for (const file of controller.files) { clearBookmarks(file); } @@ -194,20 +200,14 @@ export async function activate(context: vscode.ExtensionContext) { vscode.commands.registerCommand("numberedBookmarks.listFromAllFiles", async () => { - let listController: Controller; - if (controllers.length > 1) { - const picked = await pickController(controllers); - if (!picked) { - return; - } - listController = picked; - } else { - listController = activeController; + const controller = await pickController(controllers, activeController); + if (!controller) { + return } // no bookmark let someFileHasBookmark: boolean; - for (const file of listController.files) { + for (const file of controller.files) { someFileHasBookmark = someFileHasBookmark || hasBookmarks(file); if (someFileHasBookmark) break; } @@ -223,9 +223,9 @@ export async function activate(context: vscode.ExtensionContext) { const currentLine: number = vscode.window.activeTextEditor ? vscode.window.activeTextEditor.selection.active.line + 1 : -1; // tslint:disable-next-line:prefer-for-of - for (let index = 0; index < listController.files.length; index++) { - const file = listController.files[ index ]; - const pp = listBookmarks(file, listController.workspaceFolder); + for (let index = 0; index < controller.files.length; index++) { + const file = controller.files[ index ]; + const pp = listBookmarks(file, controller.workspaceFolder); promisses.push(pp); } @@ -239,7 +239,7 @@ export async function activate(context: vscode.ExtensionContext) { const elementInside = element[ indexInside ]; if (activeTextEditor && - elementInside.detail.toString().toLocaleLowerCase() === getRelativePath(listController.workspaceFolder?.uri?.path, activeTextEditor.document.uri.path).toLocaleLowerCase()) { + elementInside.detail.toString().toLocaleLowerCase() === getRelativePath(controller.workspaceFolder?.uri?.path, activeTextEditor.document.uri.path).toLocaleLowerCase()) { items.push( { label: elementInside.label, diff --git a/vscode-numbered-bookmarks-core b/vscode-numbered-bookmarks-core index a12cce9..2292590 160000 --- a/vscode-numbered-bookmarks-core +++ b/vscode-numbered-bookmarks-core @@ -1 +1 @@ -Subproject commit a12cce924b839c3af0d70283cb509a12b1803b60 +Subproject commit 22925908c1ec896896b601e51346a0f995092c81