Small tweaks to input handler

This commit is contained in:
Alex Dima 2021-11-29 21:37:37 +01:00
parent dd56064202
commit 0685366bdf
No known key found for this signature in database
GPG key ID: 39563C1504FDD0C9

View file

@ -352,6 +352,10 @@ export class TextAreaInput extends Disposable {
}));
this._register(this._textArea.onInput((e) => {
if (_debugComposition) {
console.log(`[input]`, e);
}
// Pretend here we touched the text area, as the `input` event will most likely
// result in a `selectionchange` event which we want to ignore
this._textArea.setIgnoreSelectionChangeTime('received input event');
@ -369,12 +373,18 @@ export class TextAreaInput extends Disposable {
}
this._textAreaState = newState;
const typeInputIsNoOp = (
typeInput.text === ''
&& typeInput.replacePrevCharCnt === 0
&& typeInput.replaceNextCharCnt === 0
&& typeInput.positionDelta === 0
);
if (this._nextCommand === ReadFromTextArea.Type) {
if (typeInput.text !== '' || typeInput.replacePrevCharCnt !== 0) {
if (!typeInputIsNoOp) {
this._onType.fire(typeInput);
}
} else {
if (typeInput.text !== '' || typeInput.replacePrevCharCnt !== 0) {
if (!typeInputIsNoOp) {
this._firePaste(typeInput.text, null);
}
this._nextCommand = ReadFromTextArea.Type;