提交 3445fcb5 编写于 作者: J jeanp413

Fix #80238

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