Skip to content

Commit 93f610f

Browse files
authored
Adopt slash command for notebook. (microsoft#182077)
1 parent 4c45cff commit 93f610f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/vs/workbench/contrib/notebook/browser/controller/executeActions.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
88
import { URI, UriComponents } from 'vs/base/common/uri';
99
import { CancellationTokenSource } from 'vs/base/common/cancellation';
1010
import { ITextModel } from 'vs/editor/common/model';
11+
import { Range } from 'vs/editor/common/core/range';
1112
import { ISelection } from 'vs/editor/common/core/selection';
1213
import { ILanguageService } from 'vs/editor/common/languages/language';
1314
import { localize } from 'vs/nls';
@@ -30,6 +31,7 @@ import { Schemas } from 'vs/base/common/network';
3031
import { IDebugService } from 'vs/workbench/contrib/debug/common/debug';
3132
import { IInteractiveEditorRequest, IInteractiveEditorService } from 'vs/workbench/contrib/interactiveEditor/common/interactiveEditor';
3233
import { ICellRange } from 'vs/workbench/contrib/notebook/common/notebookRange';
34+
import { EditOperation } from 'vs/editor/common/core/editOperation';
3335

3436
const EXECUTE_NOTEBOOK_COMMAND_ID = 'notebook.execute';
3537
const CANCEL_NOTEBOOK_COMMAND_ID = 'notebook.cancelExecution';
@@ -818,16 +820,18 @@ registerAction2(class FixCellErrorction extends NotebookCellAction<ICellRange> {
818820
}
819821

820822
const request: IInteractiveEditorRequest = {
821-
prompt: `Tweak the code to fix error: ${err.message}, and keep original code`,
823+
prompt: `/fix ${err.message}`,
822824
selection: selection,
823825
wholeRange: textModel.getFullModelRange()
824826
};
825827

826828
const reply = await provider.provideResponse(session, request, _ctsSession.token);
827829

828830
if (reply && reply.type === 'editorEdit') {
829-
console.log(reply);
830-
textModel.applyEdits(reply.edits);
831+
textModel.pushStackElement();
832+
const edits = reply.edits.map(edit => EditOperation.replace(Range.lift(edit.range), edit.text));
833+
textModel.pushEditOperations(null, edits, () => null);
834+
textModel.pushStackElement();
831835
}
832836

833837
context.notebookEditor.hideProgress();

0 commit comments

Comments
 (0)