File tree 2 files changed +4
-7
lines changed
2 files changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ describe('Path Type Tests', async () => {
52
52
await vscode . window . showNotebookDocument ( notebook ) ;
53
53
await vscode . workspace . getConfiguration ( 'jsonpath-notebook' ) . update ( 'useRelativePaths' , true , true ) ;
54
54
55
- const contextUri = vscode . Uri . file ( 'C :\\input\\bookstore.json' ) ;
55
+ const contextUri = vscode . Uri . file ( 'Z :\\input\\bookstore.json' ) ;
56
56
57
57
const expectedPath = contextUri . path ;
58
58
const actualPath = getPreferredPathFormatFromUri ( contextUri ) ;
Original file line number Diff line number Diff line change @@ -34,16 +34,13 @@ export const getPreferredPathFormatFromUri = (uri: vscode.Uri): string => {
34
34
// check if notebook is open
35
35
const notebookUri = vscode . window . activeNotebookEditor ?. notebook . uri ;
36
36
if ( useRelativePaths && notebookUri ) {
37
- const notebookPath = notebookUri . path ;
38
- const contextPath = uri . path ;
39
-
40
37
// check if both files are on the same drive
41
38
// if not, use absolute path
42
- const notebookRoot = path . parse ( notebookPath ) . root ;
43
- const contextRoot = path . parse ( contextPath ) . root ;
39
+ const notebookRoot = path . parse ( notebookUri . fsPath ) . root ;
40
+ const contextRoot = path . parse ( uri . fsPath ) . root ;
44
41
if ( notebookRoot === contextRoot ) {
45
42
// use relative path
46
- filePath = path . relative ( path . dirname ( notebookPath ) , contextPath ) ;
43
+ filePath = path . relative ( path . dirname ( notebookUri . path ) , uri . path ) ;
47
44
}
48
45
}
49
46
return filePath ;
You can’t perform that action at this time.
0 commit comments