11import {
2- commands ,
3- window ,
42 NotebookController ,
53 NotebookEditor ,
64 ViewColumn ,
@@ -9,11 +7,13 @@ import {
97 NotebookCellKind ,
108 NotebookEdit ,
119 WorkspaceEdit ,
12- workspace ,
1310 Uri ,
1411} from 'vscode' ;
1512import { getExistingReplViewColumn , getTabNameForUri } from './replUtils' ;
1613import { PVSC_EXTENSION_ID } from '../common/constants' ;
14+ import { showNotebookDocument } from '../common/vscodeApis/windowApis' ;
15+ import { openNotebookDocument , applyEdit } from '../common/vscodeApis/workspaceApis' ;
16+ import { executeCommand } from '../common/vscodeApis/commandApis' ;
1717
1818/**
1919 * Function that opens/show REPL using IW UI.
@@ -26,17 +26,17 @@ export async function openInteractiveREPL(
2626 let viewColumn = ViewColumn . Beside ;
2727 if ( notebookDocument instanceof Uri ) {
2828 // Case where NotebookDocument is undefined, but workspace mementoURI exists.
29- notebookDocument = await workspace . openNotebookDocument ( notebookDocument ) ;
29+ notebookDocument = await openNotebookDocument ( notebookDocument ) ;
3030 } else if ( notebookDocument ) {
3131 // Case where NotebookDocument (REPL document already exists in the tab)
3232 const existingReplViewColumn = getExistingReplViewColumn ( notebookDocument ) ;
3333 viewColumn = existingReplViewColumn ?? viewColumn ;
3434 } else if ( ! notebookDocument ) {
3535 // Case where NotebookDocument doesnt exist, or
3636 // became outdated (untitled.ipynb created without Python extension knowing, effectively taking over original Python REPL's URI)
37- notebookDocument = await workspace . openNotebookDocument ( 'jupyter-notebook' ) ;
37+ notebookDocument = await openNotebookDocument ( 'jupyter-notebook' ) ;
3838 }
39- const editor = await window . showNotebookDocument ( notebookDocument ! , {
39+ const editor = await showNotebookDocument ( notebookDocument ! , {
4040 viewColumn,
4141 asRepl : 'Python REPL' ,
4242 preserveFocus,
@@ -52,7 +52,7 @@ export async function openInteractiveREPL(
5252 return undefined ;
5353 }
5454
55- await commands . executeCommand ( 'notebook.selectKernel' , {
55+ await executeCommand ( 'notebook.selectKernel' , {
5656 editor,
5757 id : notebookController . id ,
5858 extension : PVSC_EXTENSION_ID ,
@@ -69,7 +69,7 @@ export async function selectNotebookKernel(
6969 notebookControllerId : string ,
7070 extensionId : string ,
7171) : Promise < void > {
72- await commands . executeCommand ( 'notebook.selectKernel' , {
72+ await executeCommand ( 'notebook.selectKernel' , {
7373 notebookEditor,
7474 id : notebookControllerId ,
7575 extension : extensionId ,
@@ -84,7 +84,7 @@ export async function executeNotebookCell(notebookEditor: NotebookEditor, code:
8484 const cellIndex = replOptions ?. appendIndex ?? notebook . cellCount ;
8585 await addCellToNotebook ( notebook , cellIndex , code ) ;
8686 // Execute the cell
87- commands . executeCommand ( 'notebook.cell.execute' , {
87+ executeCommand ( 'notebook.cell.execute' , {
8888 ranges : [ { start : cellIndex , end : cellIndex + 1 } ] ,
8989 document : notebook . uri ,
9090 } ) ;
@@ -100,5 +100,5 @@ async function addCellToNotebook(notebookDocument: NotebookDocument, index: numb
100100 const notebookEdit = NotebookEdit . insertCells ( index , [ notebookCellData ] ) ;
101101 const workspaceEdit = new WorkspaceEdit ( ) ;
102102 workspaceEdit . set ( notebookDocument ! . uri , [ notebookEdit ] ) ;
103- await workspace . applyEdit ( workspaceEdit ) ;
103+ await applyEdit ( workspaceEdit ) ;
104104}
0 commit comments