From f324ef4adfa83242010f5fe7d0eda2d39fd51bfb Mon Sep 17 00:00:00 2001 From: Aiday Marlen Kyzy Date: Fri, 27 Sep 2024 10:05:39 +0200 Subject: [PATCH 1/2] adding code --- .../editContext/native/nativeEditContext.ts | 11 ++++++- src/vs/editor/browser/view.ts | 31 +++++++++++++------ 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/vs/editor/browser/controller/editContext/native/nativeEditContext.ts b/src/vs/editor/browser/controller/editContext/native/nativeEditContext.ts index 67cdd3b0bb07d..c8aa04c7ab6e0 100644 --- a/src/vs/editor/browser/controller/editContext/native/nativeEditContext.ts +++ b/src/vs/editor/browser/controller/editContext/native/nativeEditContext.ts @@ -26,6 +26,7 @@ import { Selection } from '../../../../common/core/selection.js'; import { Position } from '../../../../common/core/position.js'; import { IVisibleRangeProvider } from '../textArea/textAreaEditContext.js'; import { PositionOffsetTransformer } from '../../../../common/core/positionToOffset.js'; +import { CodeWindow } from '../../../../../base/browser/window.js'; // Corresponds to classes in nativeEditContext.css enum CompositionClassName { @@ -51,6 +52,7 @@ export class NativeEditContext extends AbstractEditContext { constructor( context: ViewContext, + ownerWindow: CodeWindow, viewController: ViewController, private readonly _visibleRangeProvider: IVisibleRangeProvider, @IInstantiationService instantiationService: IInstantiationService, @@ -64,7 +66,11 @@ export class NativeEditContext extends AbstractEditContext { this._focusTracker = this._register(new FocusTracker(this.domNode.domNode, (newFocusValue: boolean) => this._context.viewModel.setHasFocus(newFocusValue))); - this._editContext = new EditContext(); + const doesEditContextExist = 'EditContext' in ownerWindow; + console.log('doesEditContextExist : ', doesEditContextExist); + this._editContext = new ownerWindow.EditContext(); + console.log('after creating edit context'); + console.log('this._editContext : ', this._editContext); this.domNode.domNode.editContext = this._editContext; this._screenReaderSupport = instantiationService.createInstance(ScreenReaderSupport, this.domNode, context); @@ -96,9 +102,11 @@ export class NativeEditContext extends AbstractEditContext { this._register(editContextAddDisposableListener(this._editContext, 'textformatupdate', (e) => this._handleTextFormatUpdate(e))); this._register(editContextAddDisposableListener(this._editContext, 'characterboundsupdate', (e) => this._updateCharacterBounds(e))); this._register(editContextAddDisposableListener(this._editContext, 'textupdate', (e) => { + console.log('text update : ', e); this._emitTypeEvent(viewController, e); })); this._register(editContextAddDisposableListener(this._editContext, 'compositionstart', (e) => { + console.log('composition start : ', e); // Utlimately fires onDidCompositionStart() on the editor to notify for example suggest model of composition state // Updates the composition state of the cursor controller which determines behavior of typing with interceptors viewController.compositionStart(); @@ -106,6 +114,7 @@ export class NativeEditContext extends AbstractEditContext { this._context.viewModel.onCompositionStart(); })); this._register(editContextAddDisposableListener(this._editContext, 'compositionend', (e) => { + console.log('composition end : ', e); // Utlimately fires compositionEnd() on the editor to notify for example suggest model of composition state // Updates the composition state of the cursor controller which determines behavior of typing with interceptors viewController.compositionEnd(); diff --git a/src/vs/editor/browser/view.ts b/src/vs/editor/browser/view.ts index b55cfa1e0c110..61d8b776db37c 100644 --- a/src/vs/editor/browser/view.ts +++ b/src/vs/editor/browser/view.ts @@ -134,10 +134,20 @@ export class View extends ViewEventHandler { this._viewParts = []; + this.domNode = createFastDomNode(document.createElement('div')); + this.domNode.setAttribute('role', 'code'); + + this._overflowGuardContainer = createFastDomNode(document.createElement('div')); + PartFingerprints.write(this._overflowGuardContainer, PartFingerprint.OverflowGuard); + this._overflowGuardContainer.setClassName('overflow-guard'); + // Keyboard handler this._experimentalEditContextEnabled = this._context.configuration.options.get(EditorOption.experimentalEditContextEnabled); this._editContext = this._instantiateEditContext(this._experimentalEditContextEnabled); + this.domNode.setClassName(this._getEditorClassName()); + // Set role 'code' for better screen reader support https://github.com/microsoft/vscode/issues/93438 + this._viewParts.push(this._editContext); // These two dom nodes must be constructed up front, since references are needed in the layout provider (scrolling & co.) @@ -145,19 +155,10 @@ export class View extends ViewEventHandler { this._linesContent.setClassName('lines-content' + ' monaco-editor-background'); this._linesContent.setPosition('absolute'); - this.domNode = createFastDomNode(document.createElement('div')); - this.domNode.setClassName(this._getEditorClassName()); - // Set role 'code' for better screen reader support https://github.com/microsoft/vscode/issues/93438 - this.domNode.setAttribute('role', 'code'); - if (this._context.configuration.options.get(EditorOption.experimentalGpuAcceleration) === 'on') { this._viewGpuContext = this._instantiationService.createInstance(ViewGpuContext, this._context); } - this._overflowGuardContainer = createFastDomNode(document.createElement('div')); - PartFingerprints.write(this._overflowGuardContainer, PartFingerprint.OverflowGuard); - this._overflowGuardContainer.setClassName('overflow-guard'); - this._scrollbar = new EditorScrollbar(this._context, this._linesContent, this.domNode, this._overflowGuardContainer); this._viewParts.push(this._scrollbar); @@ -268,7 +269,17 @@ export class View extends ViewEventHandler { } private _instantiateEditContext(experimentalEditContextEnabled: boolean): AbstractEditContext { - return this._instantiationService.createInstance(experimentalEditContextEnabled ? NativeEditContext : TextAreaEditContext, this._context, this._viewController, this._createTextAreaHandlerHelper()); + if (experimentalEditContextEnabled) { + const ownerWindow = dom.getWindow(this.domNode.domNode); + const document = ownerWindow.document; + console.log('this.domNode.domNode : ', this.domNode.domNode); + console.log('this._overflowGuardContainer : ', this._overflowGuardContainer); + console.log('ownerWindow : ', ownerWindow); + console.log('document : ', document); + return this._instantiationService.createInstance(NativeEditContext, this._context, ownerWindow, this._viewController, this._createTextAreaHandlerHelper()); + } else { + return this._instantiationService.createInstance(TextAreaEditContext, this._context, this._viewController, this._createTextAreaHandlerHelper()); + } } private _updateEditContext(): void { From 14d336a073423cd0d117a689eb543b0d848846e0 Mon Sep 17 00:00:00 2001 From: Aiday Marlen Kyzy Date: Fri, 27 Sep 2024 11:33:43 +0200 Subject: [PATCH 2/2] add some more code --- .../browser/controller/editContext/native/nativeEditContext.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/vs/editor/browser/controller/editContext/native/nativeEditContext.ts b/src/vs/editor/browser/controller/editContext/native/nativeEditContext.ts index c8aa04c7ab6e0..480496b703e47 100644 --- a/src/vs/editor/browser/controller/editContext/native/nativeEditContext.ts +++ b/src/vs/editor/browser/controller/editContext/native/nativeEditContext.ts @@ -71,6 +71,7 @@ export class NativeEditContext extends AbstractEditContext { this._editContext = new ownerWindow.EditContext(); console.log('after creating edit context'); console.log('this._editContext : ', this._editContext); + console.log('this.domNode.domNode : ', this.domNode.domNode); this.domNode.domNode.editContext = this._editContext; this._screenReaderSupport = instantiationService.createInstance(ScreenReaderSupport, this.domNode, context);