File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -125,7 +125,21 @@ export type PythonApi = {
125
125
interpreter ?: PythonEnvironment_PythonApi
126
126
) : Promise < string [ ] | undefined > ;
127
127
128
+ /**
129
+ * Call to provide a function that the Python extension can call to request the Python
130
+ * path to use for a particular notebook.
131
+ * @param func : The function that Python should call when requesting the Python path.
132
+ */
128
133
registerJupyterPythonPathFunction ( func : ( uri : Uri ) => Promise < string | undefined > ) : void ;
134
+
135
+ /**
136
+ * Call to provide a function that the Python extension can call to request the notebook
137
+ * document URI related to a particular text document URI, or undefined if there is no
138
+ * associated notebook.
139
+ * @param func : The function that Python should call when requesting the notebook URI.
140
+ */
141
+ registerGetNotebookUriForTextDocumentUriFunction ( func : ( textDocumentUri : Uri ) => Uri | undefined ) : void ;
142
+
129
143
/**
130
144
* This API will re-trigger environment discovery. Extensions can wait on the returned
131
145
* promise to get the updated interpreters list. If there is a refresh already going on
Original file line number Diff line number Diff line change @@ -47,6 +47,11 @@ export class NotebookPythonPathService implements IExtensionSingleActivationServ
47
47
if ( api . registerJupyterPythonPathFunction !== undefined ) {
48
48
api . registerJupyterPythonPathFunction ( ( uri ) => this . _jupyterPythonPathFunction ( uri ) ) ;
49
49
}
50
+ if ( api . registerGetNotebookUriForTextDocumentUriFunction !== undefined ) {
51
+ api . registerGetNotebookUriForTextDocumentUriFunction ( ( uri ) =>
52
+ this . _getNotebookUriForTextDocumentUri ( uri )
53
+ ) ;
54
+ }
50
55
} ) ;
51
56
}
52
57
@@ -138,4 +143,14 @@ export class NotebookPythonPathService implements IExtensionSingleActivationServ
138
143
139
144
return pythonPath ;
140
145
}
146
+
147
+ private _getNotebookUriForTextDocumentUri ( textDocumentUri : Uri ) : Uri | undefined {
148
+ if ( textDocumentUri . scheme !== 'vscode-interactive-input' ) {
149
+ return undefined ;
150
+ }
151
+
152
+ const notebookPath = `${ textDocumentUri . fsPath . replace ( '\\InteractiveInput-' , 'Interactive-' ) } .interactive` ;
153
+ const notebookUri = textDocumentUri . with ( { scheme : 'vscode-interactive' , path : notebookPath } ) ;
154
+ return notebookUri ;
155
+ }
141
156
}
You can’t perform that action at this time.
0 commit comments