Skip to content

Commit

Permalink
Add workspace/controller picker for clear
Browse files Browse the repository at this point in the history
  • Loading branch information
alefragnani committed Feb 10, 2021
1 parent 86901ac commit b314310
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
32 changes: 16 additions & 16 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
}

Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion vscode-numbered-bookmarks-core

0 comments on commit b314310

Please # to comment.