Initialize state explicitly

This commit is contained in:
Alex Dima 2021-11-29 19:49:59 +01:00
parent 8fc6c52059
commit 2f066a3675
No known key found for this signature in database
GPG key ID: 39563C1504FDD0C9
2 changed files with 17 additions and 15 deletions

View file

@ -460,6 +460,11 @@ export class TextAreaInput extends Disposable {
}));
}
_initializeFromTest(): void {
this._hasFocus = true;
this._textAreaState = TextAreaState.readFromTextArea(this._textArea);
}
private _installSelectionChangeListener(): IDisposable {
// See https://github.com/microsoft/vscode/issues/27216 and https://github.com/microsoft/vscode/issues/98256
// When using a Braille display, it is possible for users to reposition the

View file

@ -47,14 +47,7 @@ suite('TextAreaInput', () => {
throw new Error('Function not implemented.');
},
getScreenReaderContent: function (currentState: TextAreaState): TextAreaState {
return new TextAreaState(
recorded.initial.value,
recorded.initial.selectionStart,
recorded.initial.selectionEnd,
null,
null
);
// return TextAreaState.selectedText('<SCREEN READER CONTENT>');
return new TextAreaState('', 0, 0, null, null);
},
deduceModelPosition: function (viewAnchorPosition: Position, deltaOffset: number, lineFeedCnt: number): Position {
throw new Error('Function not implemented.');
@ -88,10 +81,7 @@ suite('TextAreaInput', () => {
readonly onCut = Event.None;
readonly onCopy = Event.None;
readonly onPaste = Event.None;
readonly _onFocus = this._register(new Emitter<FocusEvent>());
readonly onFocus = this._onFocus.event;
readonly onFocus = Event.None;
readonly onBlur = Event.None;
readonly onSyntheticTap = Event.None;
@ -107,7 +97,13 @@ suite('TextAreaInput', () => {
};
}
public dispatchRecordedEvent(event: IRecordedEvent): void {
public _initialize(state: IRecordedTextareaState): void {
this._state.value = state.value;
this._state.selectionStart = state.selectionStart;
this._state.selectionEnd = state.selectionEnd;
}
public _dispatchRecordedEvent(event: IRecordedEvent): void {
this._state.value = event.state.value;
this._state.selectionStart = event.state.selectionStart;
this._state.selectionEnd = event.state.selectionEnd;
@ -193,7 +189,8 @@ suite('TextAreaInput', () => {
});
const input = disposables.add(new TextAreaInput(host, wrapper, recorded.env.OS, recorded.env.browser));
wrapper._onFocus.fire(null as any);
wrapper._initialize(recorded.initial);
input._initializeFromTest();
let outgoingEvents: OutoingEvent[] = [];
@ -217,7 +214,7 @@ suite('TextAreaInput', () => {
})));
for (const event of recorded.events) {
wrapper.dispatchRecordedEvent(event);
wrapper._dispatchRecordedEvent(event);
await yieldNow();
}