未验证 提交 fc2e39fc 编写于 作者: R Rob Lourens 提交者: GitHub

Merge pull request #80241 from jeanp413/fix-focus-search-results

Fix focus next/prev search result command inconsistent behavior
......@@ -711,7 +711,7 @@ export class SearchView extends ViewletPanel {
const [selected] = this.tree.getSelection();
// Expand the initial selected node, if needed
if (selected instanceof FileMatch) {
if (selected && !(selected instanceof Match)) {
if (this.tree.isCollapsed(selected)) {
this.tree.expand(selected);
}
......@@ -721,18 +721,16 @@ export class SearchView extends ViewletPanel {
let next = navigator.next();
if (!next) {
// Reached the end - get a new navigator from the root.
navigator = this.tree.navigate();
next = navigator.first();
}
// Expand and go past FileMatch nodes
// Expand until first child is a Match
while (!(next instanceof Match)) {
if (this.tree.isCollapsed(next)) {
this.tree.expand(next);
}
// Select the FileMatch's first child
// Select the first child
next = navigator.next();
}
......@@ -752,30 +750,17 @@ export class SearchView extends ViewletPanel {
let prev = navigator.previous();
// Expand and go past FileMatch nodes
if (!(prev instanceof Match)) {
prev = navigator.previous();
if (!prev) {
// Wrap around
prev = navigator.last();
// This is complicated because .last will set the navigator to the last FileMatch,
// so expand it and FF to its last child
this.tree.expand(prev);
let tmp: RenderableMatch | null;
while (tmp = navigator.next()) {
prev = tmp;
}
}
// Select previous until find a Match or a collapsed item
while (!prev || (!(prev instanceof Match) && !this.tree.isCollapsed(prev))) {
prev = prev ? navigator.previous() : navigator.last();
}
if (!(prev instanceof Match)) {
// There is a second non-Match result, which must be a collapsed FileMatch.
// Expand it then select its last child.
const nextItem = navigator.next();
this.tree.expand(prev);
navigator = this.tree.navigate(nextItem); // recreate navigator because modifying the tree can invalidate it
prev = navigator.previous();
}
// Expand until last child is a Match
while (!(prev instanceof Match)) {
const nextItem = navigator.next();
this.tree.expand(prev);
navigator = this.tree.navigate(nextItem); // recreate navigator because modifying the tree can invalidate it
prev = nextItem ? navigator.previous() : navigator.last(); // select last child
}
// Reveal the newly selected element
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册