mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Fixes #138095: Do not touch the textarea during a compositionstart
event
This commit is contained in:
parent
9fc5b78314
commit
31fff5074d
|
@ -293,6 +293,11 @@ export class TextAreaHandler extends ViewPart {
|
|||
visibleRange.left,
|
||||
canUseZeroSizeTextarea ? 0 : 1
|
||||
);
|
||||
// The textarea might contain more than just the currently composed text
|
||||
// so we will scroll the textarea as much as possible to the left, which
|
||||
// means that the browser will perfectly center the currently composed text
|
||||
// when it scrolls to the right to reveal the textarea cursor.
|
||||
this.textArea.domNode.scrollLeft = 0;
|
||||
this._render();
|
||||
}
|
||||
|
||||
|
@ -309,6 +314,11 @@ export class TextAreaHandler extends ViewPart {
|
|||
}
|
||||
// adjust width by its size
|
||||
this._visibleTextArea = this._visibleTextArea.setWidth(measureText(e.data, this._fontInfo));
|
||||
// The textarea might contain more than just the currently composed text
|
||||
// so we will scroll the textarea as much as possible to the left, which
|
||||
// means that the browser will perfectly center the currently composed text
|
||||
// when it scrolls to the right to reveal the textarea cursor.
|
||||
this.textArea.domNode.scrollLeft = 0;
|
||||
this._render();
|
||||
}));
|
||||
|
||||
|
|
|
@ -289,7 +289,6 @@ export class TextAreaInput extends Disposable {
|
|||
return;
|
||||
}
|
||||
|
||||
this._setAndWriteTextAreaState('compositionstart', TextAreaState.EMPTY);
|
||||
this._onCompositionStart.fire({ revealDeltaColumns: 0 });
|
||||
}));
|
||||
|
||||
|
|
|
@ -86,6 +86,7 @@ suite('TextAreaInput', () => {
|
|||
readonly onSyntheticTap = Event.None;
|
||||
|
||||
private _state: IRecordedTextareaState;
|
||||
private _currDispatchingEvent: IRecordedEvent | null;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
@ -95,6 +96,7 @@ suite('TextAreaInput', () => {
|
|||
selectionStart: 0,
|
||||
value: ''
|
||||
};
|
||||
this._currDispatchingEvent = null;
|
||||
}
|
||||
|
||||
public _initialize(state: IRecordedTextareaState): void {
|
||||
|
@ -104,6 +106,7 @@ suite('TextAreaInput', () => {
|
|||
}
|
||||
|
||||
public _dispatchRecordedEvent(event: IRecordedEvent): void {
|
||||
this._currDispatchingEvent = event;
|
||||
this._state.value = event.state.value;
|
||||
this._state.selectionStart = event.state.selectionStart;
|
||||
this._state.selectionEnd = event.state.selectionEnd;
|
||||
|
@ -161,12 +164,16 @@ suite('TextAreaInput', () => {
|
|||
} else {
|
||||
throw new Error(`Not Implemented`);
|
||||
}
|
||||
this._currDispatchingEvent = null;
|
||||
}
|
||||
|
||||
getValue(): string {
|
||||
return this._state.value;
|
||||
}
|
||||
setValue(reason: string, value: string): void {
|
||||
if (this._currDispatchingEvent?.type === 'compositionstart') {
|
||||
assert.fail('should not change the state of the textarea in a compositionstart');
|
||||
}
|
||||
this._state.value = value;
|
||||
}
|
||||
getSelectionStart(): number {
|
||||
|
@ -176,6 +183,9 @@ suite('TextAreaInput', () => {
|
|||
return this._state.selectionDirection === 'backward' ? this._state.selectionStart : this._state.selectionEnd;
|
||||
}
|
||||
setSelectionRange(reason: string, selectionStart: number, selectionEnd: number): void {
|
||||
if (this._currDispatchingEvent?.type === 'compositionstart') {
|
||||
assert.fail('should not change the state of the textarea in a compositionstart');
|
||||
}
|
||||
this._state.selectionStart = selectionStart;
|
||||
this._state.selectionEnd = selectionEnd;
|
||||
this._state.selectionDirection = (selectionStart !== selectionEnd ? 'forward' : 'none');
|
||||
|
|
Loading…
Reference in a new issue