Skip to content

Commit 146aa64

Browse files
Notebook cell to/from fspath
1 parent 4acb66b commit 146aa64

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

libs/shared/src/lib/idl-file-helper.class.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,23 @@ export class IDLFileHelper {
6262
static notebookCellUriToFSPath(uri: URI) {
6363
return join(
6464
CleanPath(dirname(uri.fsPath)),
65-
`${basename(uri.fsPath, IDL_NOTEBOOK_EXTENSION).replace(
66-
/\s/g,
67-
'_'
65+
`${basename(
66+
uri.fsPath,
67+
IDL_NOTEBOOK_EXTENSION
6868
)}_${NOTEBOOK_CELL_BASE_NAME}_${uri.fragment}.pro`
6969
);
7070
}
71+
72+
/**
73+
* Converts a file system path for a notebook call back to a URI for
74+
* a notebook cell
75+
*/
76+
static notebookCellFSPathToUri(fsPath: string) {
77+
const split = fsPath.split(`_${NOTEBOOK_CELL_BASE_NAME}_`);
78+
return URI.from({
79+
scheme: 'vscode-notebook-cell',
80+
path: `/${split[0].replace(/\\/g, '/')}${IDL_NOTEBOOK_EXTENSION}`,
81+
fragment: basename(split[1], `.pro`),
82+
});
83+
}
7184
}

0 commit comments

Comments
 (0)