diff --git a/src/vs/workbench/contrib/search/browser/searchWidget.ts b/src/vs/workbench/contrib/search/browser/searchWidget.ts index d5b80134341..52daf5fda2d 100644 --- a/src/vs/workbench/contrib/search/browser/searchWidget.ts +++ b/src/vs/workbench/contrib/search/browser/searchWidget.ts @@ -665,6 +665,25 @@ export class SearchWidget extends Widget { else if (keyboardEvent.equals(KeyCode.DownArrow)) { stopPropagationForMultiLineDownwards(keyboardEvent, this.searchInput?.getValue() ?? '', this.searchInput?.domNode.querySelector('textarea') ?? null); } + + else if (keyboardEvent.equals(KeyCode.PageUp)) { + const inputElement = this.searchInput?.inputBox.inputElement; + if (inputElement) { + inputElement.setSelectionRange(0, 0); + inputElement.focus(); + keyboardEvent.preventDefault(); + } + } + + else if (keyboardEvent.equals(KeyCode.PageDown)) { + const inputElement = this.searchInput?.inputBox.inputElement; + if (inputElement) { + const endOfText = inputElement.value.length; + inputElement.setSelectionRange(endOfText, endOfText); + inputElement.focus(); + keyboardEvent.preventDefault(); + } + } } private onCaseSensitiveKeyDown(keyboardEvent: IKeyboardEvent) { diff --git a/test/automation/src/search.ts b/test/automation/src/search.ts index 567ec20fa91..5cf6018b72a 100644 --- a/test/automation/src/search.ts +++ b/test/automation/src/search.ts @@ -61,6 +61,21 @@ export class Search extends Viewlet { await this.submitSearch(); } + async hasActivityBarMoved() { + await this.code.waitForElement('.activitybar'); + + const elementBoundingBox = await this.code.driver.getElementXY('.activitybar'); + return elementBoundingBox !== null && elementBoundingBox.x === 48 && elementBoundingBox.y === 375; + } + + async waitForPageUp(): Promise { + await this.code.dispatchKeybinding('PageUp'); + } + + async waitForPageDown(): Promise { + await this.code.dispatchKeybinding('PageDown'); + } + async submitSearch(): Promise { await this.waitForInputFocus(INPUT); diff --git a/test/smoke/src/areas/search/search.test.ts b/test/smoke/src/areas/search/search.test.ts index 92c75f14404..78f79b61838 100644 --- a/test/smoke/src/areas/search/search.test.ts +++ b/test/smoke/src/areas/search/search.test.ts @@ -19,6 +19,17 @@ export function setup(logger: Logger) { retry(async () => cp.execSync('git reset --hard HEAD --quiet', { cwd: app.workspacePathOrFolder }), 0, 5); }); + it('verifies the sidebar moves to the right', async function () { + const app = this.app as Application; + await app.workbench.search.openSearchViewlet(); + + await app.code.dispatchKeybinding('PageUp'); + await app.workbench.search.hasActivityBarMoved(); + + await app.code.dispatchKeybinding('PageUp'); + await app.workbench.search.hasActivityBarMoved(); + }); + it('searches for body & checks for correct result number', async function () { const app = this.app as Application; await app.workbench.search.openSearchViewlet();