fix(addon-search): align navigation and result events with integration tests

- Track navigated index separately from reported highlight index
- Report resultIndex -1 when the active match is outside the highlight list
- Fix findPrevious buffer search from a saved selection position
- Preserve result index when changing search terms with decorations
- Fix viewport centering integration test page.evaluate syntax

Co-authored-by: Daniel Imms <Tyriar@users.noreply.github.com>
This commit is contained in:
Cursor Agent
2026-05-27 05:04:12 +00:00
co-authored by Daniel Imms
parent 22acf01d43
commit e60aa4bf97
2 changed files with 284 additions and 34 deletions
+1 -9
View File
@@ -79,15 +79,7 @@ test.describe('Search Tests', () => {
strictEqual(await ctx.page.evaluate(`window.search.findNext('needle-center')`), true);
deepStrictEqual(await ctx.proxy.getSelection(), 'needle-center');
deepStrictEqual(await ctx.page.evaluate(`
const viewportY = window.term.buffer.active.viewportY;
const rows = window.term.rows;
const selection = window.term.getSelectionPosition();
return {
viewportY,
expectedViewportY: selection.start.y - Math.floor(rows / 2)
};
`), {
deepStrictEqual(await ctx.page.evaluate('(() => { const viewportY = window.term.buffer.active.viewportY; const rows = window.term.rows; const selection = window.term.getSelectionPosition(); return { viewportY: viewportY, expectedViewportY: selection.start.y - Math.floor(rows / 2) }; })()'), {
viewportY: 48,
expectedViewportY: 48
});