re #128173. Only handle monaco editor textarea.
This commit is contained in:
parent
a0696fb236
commit
3d9899db8e
|
@ -11,6 +11,7 @@ import { CellKind } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||||
import { CellEditState, getNotebookEditorFromEditorPane } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
import { CellEditState, getNotebookEditorFromEditorPane } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||||
import { RedoCommand, UndoCommand } from 'vs/editor/browser/editorExtensions';
|
import { RedoCommand, UndoCommand } from 'vs/editor/browser/editorExtensions';
|
||||||
|
import { NotebookEditorWidget } from 'vs/workbench/contrib/notebook/browser/notebookEditorWidget';
|
||||||
|
|
||||||
class NotebookUndoRedoContribution extends Disposable {
|
class NotebookUndoRedoContribution extends Disposable {
|
||||||
|
|
||||||
|
@ -26,8 +27,11 @@ class NotebookUndoRedoContribution extends Disposable {
|
||||||
* We now make the notebook undo/redo impl the highest priority so we don't skip the "invalid" undo/redo element in the same notebook document
|
* We now make the notebook undo/redo impl the highest priority so we don't skip the "invalid" undo/redo element in the same notebook document
|
||||||
*/
|
*/
|
||||||
this._register(UndoCommand.addImplementation(10000 + 5, 'notebook-undo-redo', () => {
|
this._register(UndoCommand.addImplementation(10000 + 5, 'notebook-undo-redo', () => {
|
||||||
const editor = getNotebookEditorFromEditorPane(this._editorService.activeEditorPane);
|
const editor = getNotebookEditorFromEditorPane(this._editorService.activeEditorPane) as NotebookEditorWidget | undefined;
|
||||||
if (editor?.viewModel) {
|
if (editor?.hasModel()) {
|
||||||
|
const activeCodeEditor = editor.activeCodeEditor;
|
||||||
|
|
||||||
|
if (activeCodeEditor && activeCodeEditor.hasTextFocus()) {
|
||||||
return editor.viewModel.undo().then(cellResources => {
|
return editor.viewModel.undo().then(cellResources => {
|
||||||
if (cellResources?.length) {
|
if (cellResources?.length) {
|
||||||
editor?.viewModel?.viewCells.forEach(cell => {
|
editor?.viewModel?.viewCells.forEach(cell => {
|
||||||
|
@ -40,13 +44,17 @@ class NotebookUndoRedoContribution extends Disposable {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this._register(RedoCommand.addImplementation(10000 + 5, 'notebook-undo-redo', () => {
|
this._register(RedoCommand.addImplementation(10000 + 5, 'notebook-undo-redo', () => {
|
||||||
const editor = getNotebookEditorFromEditorPane(this._editorService.activeEditorPane);
|
const editor = getNotebookEditorFromEditorPane(this._editorService.activeEditorPane) as NotebookEditorWidget | undefined;
|
||||||
if (editor?.viewModel) {
|
if (editor?.hasModel()) {
|
||||||
|
const activeCodeEditor = editor.activeCodeEditor;
|
||||||
|
|
||||||
|
if (activeCodeEditor && activeCodeEditor.hasTextFocus()) {
|
||||||
return editor.viewModel.redo().then(cellResources => {
|
return editor.viewModel.redo().then(cellResources => {
|
||||||
if (cellResources?.length) {
|
if (cellResources?.length) {
|
||||||
editor?.viewModel?.viewCells.forEach(cell => {
|
editor?.viewModel?.viewCells.forEach(cell => {
|
||||||
|
@ -59,6 +67,7 @@ class NotebookUndoRedoContribution extends Disposable {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}));
|
}));
|
||||||
|
|
Loading…
Reference in a new issue