Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { IME } from '../../../../../base/common/ime.js';
import { OffsetRange } from '../../../../common/core/ranges/offsetRange.js';
import { ILogService, LogLevel } from '../../../../../platform/log/common/log.js';
import { generateUuid } from '../../../../../base/common/uuid.js';
import { inputLatency } from '../../../../../base/browser/performance.js';

// Corresponds to classes in nativeEditContext.css
enum CompositionClassName {
Expand Down Expand Up @@ -125,12 +126,16 @@ export class NativeEditContext extends AbstractEditContext {
this.logService.trace('NativeEditContext#cut (before viewController.cut)');
this._viewController.cut();
}));
this._register(addDisposableListener(this.domNode.domNode, 'selectionchange', () => {
inputLatency.onSelectionChange();
}));

this._register(addDisposableListener(this.domNode.domNode, 'keyup', (e) => this._onKeyUp(e)));
this._register(addDisposableListener(this.domNode.domNode, 'keydown', async (e) => this._onKeyDown(e)));
this._register(addDisposableListener(this._imeTextArea.domNode, 'keyup', (e) => this._onKeyUp(e)));
this._register(addDisposableListener(this._imeTextArea.domNode, 'keydown', async (e) => this._onKeyDown(e)));
this._register(addDisposableListener(this.domNode.domNode, 'beforeinput', async (e) => {
inputLatency.onBeforeInput();
if (e.inputType === 'insertParagraph' || e.inputType === 'insertLineBreak') {
this._onType(this._viewController, { text: '\n', replacePrevCharCnt: 0, replaceNextCharCnt: 0, positionDelta: 0 });
}
Expand Down Expand Up @@ -166,6 +171,7 @@ export class NativeEditContext extends AbstractEditContext {
this._register(editContextAddDisposableListener(this._editContext, 'characterboundsupdate', (e) => this._updateCharacterBounds(e)));
let highSurrogateCharacter: string | undefined;
this._register(editContextAddDisposableListener(this._editContext, 'textupdate', (e) => {
inputLatency.onInput();
Comment on lines 173 to +174
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't totally sure about this one. Is there an equivalent to input for edit context?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const text = e.text;
if (text.length === 1) {
const charCode = text.charCodeAt(0);
Expand Down Expand Up @@ -355,10 +361,12 @@ export class NativeEditContext extends AbstractEditContext {
// --- Private methods ---

private _onKeyUp(e: KeyboardEvent) {
inputLatency.onKeyUp();
this._viewController.emitKeyUp(new StandardKeyboardEvent(e));
}

private _onKeyDown(e: KeyboardEvent) {
inputLatency.onKeyDown();
const standardKeyboardEvent = new StandardKeyboardEvent(e);
// When the IME is visible, the keys, like arrow-left and arrow-right, should be used to navigate in the IME, and should not be propagated further
if (standardKeyboardEvent.keyCode === KeyCode.KEY_IN_COMPOSITION) {
Expand Down
Loading