Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | 1x 9x 1x 1x 8x 8x 1x 1x 7x 6x 7x 1x 1x 6x 6x 6x 9x 1x 1x 5x 5x 2x 3x 1x 2x 2x 2x 2x 2x 2x | import * as vscode from 'vscode';
import { container } from 'tsyringe';
import { ServiceToken } from '@src/services/tokens';
import { DocumentContextService } from '@src/services/document/document-context-service';
import { WorkspaceUri } from '@src/providers/workspace-uri';
import { findNotebookContainingCell } from '@src/utilities/vscode/notebook';
import { editNotebookCellSlug } from './edit-notebook-cell-slug';
export const triggerNotebookCellSlugAction = {
id: 'mentor.command.triggerNotebookCellSlugAction',
handler: async (cellDocumentUri: vscode.Uri) => {
if (!cellDocumentUri) {
vscode.window.showWarningMessage('No notebook cell specified.');
return;
}
const notebook = findNotebookContainingCell(cellDocumentUri);
if (!notebook) {
vscode.window.showWarningMessage('Could not find the notebook containing this cell.');
return;
}
const cell = notebook.getCells().find(
c => c.document.uri.toString() === cellDocumentUri.toString()
);
if (!cell) {
vscode.window.showWarningMessage('Could not find the notebook cell.');
return;
}
const contextService = container.resolve<DocumentContextService>(ServiceToken.DocumentContextService);
const ctx = contextService.contexts[cellDocumentUri.toString()];
const slug: string = cell.metadata?.slug ?? ctx?.slug ?? '';
if (!slug) {
vscode.window.showWarningMessage('This cell has no slug.');
return;
}
const picked = await vscode.window.showQuickPick(
[
{
id: 'edit',
label: '$(pencil) Edit ID',
description: 'Edit the ID of this cell',
},
{
id: 'copy',
label: '$(copy) Copy URI',
description: 'Copy the workspace URI of this cell',
},
],
{ title: `Cell: #${slug}` }
);
if (!picked) {
return;
}
if (picked.id === 'edit') {
await editNotebookCellSlug.handler(cellDocumentUri);
} else if (Epicked.id === 'copy') {
const workspaceUri = WorkspaceUri.toWorkspaceUri(cellDocumentUri, slug);
Eif (workspaceUri) {
const uriString = WorkspaceUri.toCanonicalString(workspaceUri);
await vscode.env.clipboard.writeText(uriString);
vscode.window.showInformationMessage(`Copied: ${uriString}`);
}
}
}
};
|