提交 58127c43 编写于 作者: R rebornix

re #99354. Focus editor only when the cell has focus.

上级 ca7cd125
......@@ -62,9 +62,7 @@ export class StatefullMarkdownCell extends Disposable {
// not first time, we don't need to create editor or bind listeners
viewCell.attachTextEditor(this.editor);
if (notebookEditor.getActiveCell() === viewCell) {
this.editor.focus();
}
this.tryFocusEditor();
this.bindEditorListeners(this.editor.getModel()!);
} else {
......@@ -97,9 +95,7 @@ export class StatefullMarkdownCell extends Disposable {
}
this.editor!.setModel(model);
if (notebookEditor.getActiveCell() === viewCell) {
this.editor!.focus();
}
this.tryFocusEditor();
const realContentHeight = this.editor!.getContentHeight();
if (realContentHeight !== editorHeight) {
......@@ -115,7 +111,7 @@ export class StatefullMarkdownCell extends Disposable {
viewCell.attachTextEditor(this.editor!);
if (viewCell.editState === CellEditState.Editing) {
this.editor!.focus();
this.tryFocusEditor();
}
this.bindEditorListeners(model, {
......@@ -135,7 +131,7 @@ export class StatefullMarkdownCell extends Disposable {
const totalHeight = editorHeight + 32 + clientHeight + CELL_STATUSBAR_HEIGHT;
this.viewCell.totalHeight = totalHeight;
notebookEditor.layoutNotebookCell(viewCell, totalHeight);
this.editor.focus();
this.tryFocusEditor();
renderedEditors.set(this.viewCell, this.editor!);
} else {
this.viewCell.detachTextEditor();
......@@ -205,7 +201,7 @@ export class StatefullMarkdownCell extends Disposable {
const updateForFocusMode = () => {
if (viewCell.focusMode === CellFocusMode.Editor) {
this.editor?.focus();
this.tryFocusEditor();
}
toggleClass(templateData.container, 'cell-editor-focus', viewCell.focusMode === CellFocusMode.Editor);
......@@ -247,6 +243,12 @@ export class StatefullMarkdownCell extends Disposable {
viewUpdate();
}
private tryFocusEditor() {
if (this.notebookEditor.getActiveCell() === this.viewCell) {
this.editor?.focus();
}
}
private layoutEditor(dimension: IDimension): void {
this.editor?.layout(dimension);
this.templateData.statusBarContainer.style.width = `${dimension.width}px`;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册