EditContext: Setting the edit context when current window id does not correspond to previous window id (#230368)

setting the edit context within nativeeditcontext
This commit is contained in:
Aiday Marlen Kyzy
2024-10-03 11:12:17 +02:00
committed by GitHub
parent 3d4417e71b
commit 3305293ba2
2 changed files with 12 additions and 8 deletions
@@ -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<IDisposable>;
@@ -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 ---
+3 -6
View File
@@ -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();