Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smoke test: Directly accepting editor selection when using text area edit context #239211

Merged
merged 3 commits into from
Jan 30, 2025
Merged
Changes from all commits
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
13 changes: 7 additions & 6 deletions test/automation/src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ export class SettingsEditor {
await this.openUserSettingsFile();

await this.code.dispatchKeybinding('right');
const selectionOffset = this._editContextSelectionOffset();
await this.editor.waitForEditorSelection('settings.json', s => s.selectionStart === selectionOffset && s.selectionEnd === selectionOffset);
await this.editor.waitForEditorSelection('settings.json', (s) => this._acceptEditorSelection(this.code.quality, s));
await this.editor.waitForTypeInEditor('settings.json', `"${setting}": ${value},`);
await this.editors.saveOpenedFile();
}
Expand All @@ -41,8 +40,7 @@ export class SettingsEditor {
await this.openUserSettingsFile();

await this.code.dispatchKeybinding('right');
const selectionOffset = this._editContextSelectionOffset();
await this.editor.waitForEditorSelection('settings.json', (s) => s.selectionStart === selectionOffset && s.selectionEnd === selectionOffset);
await this.editor.waitForEditorSelection('settings.json', (s) => this._acceptEditorSelection(this.code.quality, s));
await this.editor.waitForTypeInEditor('settings.json', settings.map(v => `"${v[0]}": ${v[1]},`).join(''));
await this.editors.saveOpenedFile();
}
Expand Down Expand Up @@ -86,7 +84,10 @@ export class SettingsEditor {
return this.code.quality === Quality.Stable ? SEARCH_BOX_TEXTAREA : SEARCH_BOX_NATIVE_EDIT_CONTEXT;
}

private _editContextSelectionOffset(): number {
return this.code.quality === Quality.Stable ? 0 : 1;
private _acceptEditorSelection(quality: Quality, s: { selectionStart: number; selectionEnd: number }): boolean {
if (quality === Quality.Stable) {
return true;
}
return s.selectionStart === 1 && s.selectionEnd === 1;
}
}
Loading