diff --git a/src/vs/editor/browser/controller/editContext/native/nativeEditContext.ts b/src/vs/editor/browser/controller/editContext/native/nativeEditContext.ts index b5c7d13ee78f..8e05b29acddb 100644 --- a/src/vs/editor/browser/controller/editContext/native/nativeEditContext.ts +++ b/src/vs/editor/browser/controller/editContext/native/nativeEditContext.ts @@ -5,7 +5,7 @@ import './nativeEditContext.css'; import { isFirefox } from '../../../../../base/browser/browser.js'; -import { addDisposableListener, getActiveWindow } from '../../../../../base/browser/dom.js'; +import { addDisposableListener, getActiveWindow, getWindow, getWindowId } from '../../../../../base/browser/dom.js'; import { FastDomNode } from '../../../../../base/browser/fastDomNode.js'; import { StandardKeyboardEvent } from '../../../../../base/browser/keyboardEvent.js'; import { KeyCode } from '../../../../../base/common/keyCodes.js'; @@ -48,6 +48,8 @@ export class NativeEditContext extends AbstractEditContext { private _textStartPositionWithinEditor: Position = new Position(1, 1); + private _targetWindowId: number = -1; + private readonly _focusTracker: FocusTracker; private readonly _selectionChangeListener: MutableDisposable; @@ -179,7 +181,12 @@ export class NativeEditContext extends AbstractEditContext { // TODO: added as a workaround fix for https://github.com/microsoft/vscode/issues/229825 // When this issue will be fixed the following should be removed. public setEditContextOnDomNode(): void { - this.domNode.domNode.editContext = this._editContext; + const targetWindow = getWindow(this.domNode.domNode); + const targetWindowId = getWindowId(targetWindow); + if (this._targetWindowId !== targetWindowId) { + this.domNode.domNode.editContext = this._editContext; + this._targetWindowId = targetWindowId; + } } // --- Private methods --- diff --git a/src/vs/editor/browser/view.ts b/src/vs/editor/browser/view.ts index 1202a39e9a76..b03406d192f7 100644 --- a/src/vs/editor/browser/view.ts +++ b/src/vs/editor/browser/view.ts @@ -111,8 +111,6 @@ export class View extends ViewEventHandler { private _shouldRecomputeGlyphMarginLanes: boolean = false; private _renderAnimationFrame: IDisposable | null; - private _targetWindow: CodeWindow | undefined; - constructor( commandDelegate: ICommandDelegate, configuration: IEditorConfiguration, @@ -458,14 +456,13 @@ export class View extends ViewEventHandler { throw new BugIndicatingError(); } if (this._renderAnimationFrame === null) { - const targetWindow = dom.getWindow(this.domNode?.domNode); - if (targetWindow !== this._targetWindow && this._editContext instanceof NativeEditContext) { + // TODO: workaround fix for https://github.com/microsoft/vscode/issues/229825 + if (this._editContext instanceof NativeEditContext) { this._editContext.setEditContextOnDomNode(); - this._targetWindow = targetWindow; } const rendering = this._createCoordinatedRendering(); this._renderAnimationFrame = EditorRenderingCoordinator.INSTANCE.scheduleCoordinatedRendering({ - window: targetWindow, + window: dom.getWindow(this.domNode?.domNode), prepareRenderText: () => { if (this._store.isDisposed) { throw new BugIndicatingError();