Skip to content

Commit ceb87a1

Browse files
committed
1 parent b3361d1 commit ceb87a1

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/vs/workbench/contrib/notebook/common/notebookCommon.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,26 +385,28 @@ export interface NotebookDataDto {
385385
export namespace CellUri {
386386

387387
export const scheme = 'vscode-notebook-cell';
388+
const _regex = /^\d{7,}/;
388389

389390
export function generate(notebook: URI, handle: number): URI {
390391
return notebook.with({
391392
scheme,
392-
fragment: `${handle}${notebook.scheme !== Schemas.file ? notebook.scheme : ''}`
393+
fragment: `${handle.toString().padStart(7, '0')}${notebook.scheme !== Schemas.file ? notebook.scheme : ''}`
393394
});
394395
}
395396

396397
export function parse(cell: URI): { notebook: URI, handle: number } | undefined {
397398
if (cell.scheme !== scheme) {
398399
return undefined;
399400
}
400-
const handle = parseInt(cell.fragment);
401-
if (isNaN(handle)) {
401+
const match = _regex.exec(cell.fragment);
402+
if (!match) {
402403
return undefined;
403404
}
405+
const handle = Number(match[0]);
404406
return {
405407
handle,
406408
notebook: cell.with({
407-
scheme: cell.fragment.substr(handle.toString().length) || Schemas.file,
409+
scheme: cell.fragment.substr(match[0].length) || Schemas.file,
408410
fragment: null
409411
})
410412
};

0 commit comments

Comments
 (0)