Skip to content

Commit 4acb66b

Browse files
WIP: Unique cell filenames for notebooks
1 parent 2f3a3f7 commit 4acb66b

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import { basename, dirname, join } from 'path';
2+
import { URI } from 'vscode-uri';
3+
4+
import { CleanPath } from './clean-path';
5+
import { NOTEBOOK_CELL_BASE_NAME } from './idl-file-helper.interface';
16
import {
27
IDL_JSON_URI,
38
IDL_NOTEBOOK_EXTENSION,
@@ -50,4 +55,17 @@ export class IDLFileHelper {
5055
static isSAVEFile(file: string): boolean {
5156
return file.toLowerCase().endsWith(IDL_SAVE_FILE_EXTENSION);
5257
}
58+
59+
/**
60+
* Converts a URI for a notebook cell to the filepath on disk that should be used
61+
*/
62+
static notebookCellUriToFSPath(uri: URI) {
63+
return join(
64+
CleanPath(dirname(uri.fsPath)),
65+
`${basename(uri.fsPath, IDL_NOTEBOOK_EXTENSION).replace(
66+
/\s/g,
67+
'_'
68+
)}_${NOTEBOOK_CELL_BASE_NAME}_${uri.fragment}.pro`
69+
);
70+
}
5371
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* Base name for notebook cell files
3+
*/
4+
export const NOTEBOOK_CELL_BASE_NAME = 'notebook_cell';

0 commit comments

Comments
 (0)