handle if the newValue.length is less than the old value by deleting

This commit is contained in:
Ian K
2022-08-08 12:41:12 -05:00
parent c021571194
commit 413a885b5e
+9 -2
View File
@@ -5,6 +5,7 @@
import { IRenderService } from 'browser/services/Services';
import { IBufferService, ICoreService, IOptionsService } from 'common/services/Services';
import { C0 } from 'common/data/EscapeSequences';
interface IPosition {
start: number;
@@ -186,11 +187,17 @@ export class CompositionHelper {
// Ignore if a composition has started since the timeout
if (!this._isComposing) {
const newValue = this._textarea.value;
const diff = newValue.replace(oldValue, '');
if (diff.length > 0) {
this._dataAlreadySent = diff;
this._dataAlreadySent = diff;
if (newValue.length > oldValue.length) {
this._coreService.triggerDataEvent(diff, true);
} else if (newValue.length < oldValue.length) {
this._coreService.triggerDataEvent(`${C0.DEL}`, true);
}
}
}, 0);
}