From ad35eabea122a8d1abe1eed882aa0b2a3424cf8b Mon Sep 17 00:00:00 2001 From: Pho Hale Date: Fri, 6 Sep 2024 10:04:20 -0400 Subject: [PATCH] cleanup for pull request --- package.json | 4 ++-- src/cellTags.ts | 53 ++++++++++++++++++++++++++---------------------- src/extension.ts | 3 --- 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/package.json b/package.json index 0e13adb..0810ae4 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ }, { "command": "jupyter-cell-tags.addTagsToSelectedCells", - "title": "🏷️➕🗂️ Add Tags to Selected Cells", + "title": "Add Tags to Selected Cells", "icon": "$(add)", "when": "jupyter-cell-tags.multipleCellsSelected" }, @@ -73,7 +73,7 @@ { "command": "jupyter-cell-tags.addTagsToSelectedCells", "when": "jupyter-cell-tags.multipleCellsSelected", - "group": "jupytercelltags@2" + "group": "jupytercelltags@1" }, { "command": "jupyter-cell-tags.editTagsInJSON", diff --git a/src/cellTags.ts b/src/cellTags.ts index e68590f..ac26397 100644 --- a/src/cellTags.ts +++ b/src/cellTags.ts @@ -184,30 +184,35 @@ export function register(context: vscode.ExtensionContext) { } const disposables: vscode.Disposable[] = []; try { - const knownTags = activeCells.map(cell => cell.metadata.custom?.metadata?.tags ?? []).flat().sort(); - const knownTagsLowerCased = new Set(knownTags.map(tag => tag.toLowerCase())); - const knownTagQuickPickItems = Array.from(new Set(knownTags)).map(tag => ({ label: tag })); - const quickPick = vscode.window.createQuickPick(); - disposables.push(quickPick); - quickPick.placeholder = 'Type to select or create a cell tag'; - quickPick.items = knownTagQuickPickItems; - quickPick.show(); - quickPick.onDidChangeValue(e => { - e = e.trim().toLowerCase(); - if (!e || knownTagsLowerCased.has(e)) { - return; - } - quickPick.items = knownTagQuickPickItems.concat({ label: e }).sort(); - }, undefined, disposables); - const tag = await new Promise(resolve => { - quickPick.onDidHide(() => resolve(''), undefined, disposables); - quickPick.onDidAccept(() => { - if (quickPick.selectedItems.length) { - resolve(quickPick.selectedItems[0].label); - quickPick.hide(); - } - }, undefined, disposables); - }); + // const knownTags = activeCells.map(cell => cell.metadata.custom?.metadata?.tags ?? []).flat().sort(); + // const knownTagsLowerCased = new Set(knownTags.map(tag => tag.toLowerCase())); + // const knownTagQuickPickItems = Array.from(new Set(knownTags)).map(tag => ({ label: tag })); + // // const quickPick = vscode.window.createQuickPick(); + // // disposables.push(quickPick); + // // quickPick.placeholder = 'Type to select or create a cell tag'; + // // quickPick.items = knownTagQuickPickItems; + // // quickPick.show(); + // // quickPick.onDidChangeValue(e => { + // // e = e.trim().toLowerCase(); + // // if (!e || knownTagsLowerCased.has(e)) { + // // return; + // // } + // // quickPick.items = knownTagQuickPickItems.concat({ label: e }).sort(); + // // }, undefined, disposables); + // const tag = await new Promise(resolve => { + // quickPick.onDidHide(() => resolve(''), undefined, disposables); + // quickPick.onDidAccept(() => { + // if (quickPick.selectedItems.length) { + // resolve(quickPick.selectedItems[0].label); + // quickPick.hide(); + // } + // }, undefined, disposables); + // }); + + const tag = await vscode.window.showInputBox({ + placeHolder: 'Type to create a cell tag' + }); + if (tag) { await addTagsToMultipleCells(activeCells, [tag]); } diff --git a/src/extension.ts b/src/extension.ts index 275f318..a9c0570 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -23,7 +23,6 @@ function updateContext() { vscode.commands.executeCommand('setContext', 'jupyter-cell-tags.singleCellSelected', false); vscode.commands.executeCommand('setContext', 'jupyter-cell-tags.multipleCellsSelected', false); console.log('No active notebook editor'); - debugSelectedCellsStatusBarItem.hide(); return; } @@ -35,8 +34,6 @@ function updateContext() { console.log(`Single cell selected: ${selectionCount === 1}`); console.log(`Multiple cells selected: ${selectionCount > 1}`); - debugSelectedCellsStatusBarItem.text = `$(notebook) ${selectionCount} Cell(s) Selected`; - debugSelectedCellsStatusBarItem.show(); }