Skip to content

Commit

Permalink
cleanup for pull request
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderPho committed Sep 6, 2024
1 parent 03779f6 commit ad35eab
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 29 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -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",
Expand Down
53 changes: 29 additions & 24 deletions src/cellTags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>(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<string>(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]);
}
Expand Down
3 changes: 0 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

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


Expand Down

0 comments on commit ad35eab

Please sign in to comment.