fixed bug with collapsing compressed nodes (#162222)

fixed bug with collapsing compression nodes
This commit is contained in:
Andrea Mah 2022-09-28 11:30:09 -07:00 committed by GitHub
parent dd4d29dd8b
commit fec2b499d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 3 deletions

View file

@ -292,14 +292,21 @@ export function collapseDeepestExpandedLevel(accessor: ServicesAccessor) {
let canCollapseFileMatchLevel = false;
let canCollapseFirstLevel = false;
if (node instanceof FolderMatch) {
if (node instanceof FolderMatchWorkspaceRoot) {
while (node = navigator.next()) {
if (node instanceof Match) {
canCollapseFileMatchLevel = true;
break;
}
if (searchView.isTreeLayoutViewVisible && !canCollapseFirstLevel) {
const immediateParent = node.parent();
let nodeToTest = node;
if (node instanceof FolderMatch) {
nodeToTest = node.compressionStartParent ?? node;
}
const immediateParent = nodeToTest.parent();
if (!(immediateParent instanceof FolderMatchWorkspaceRoot || immediateParent instanceof FolderMatchNoRoot || immediateParent instanceof SearchResult)) {
canCollapseFirstLevel = true;
}
@ -318,7 +325,14 @@ export function collapseDeepestExpandedLevel(accessor: ServicesAccessor) {
node = navigator.first();
if (node) {
do {
const immediateParent = node.parent();
let nodeToTest = node;
if (node instanceof FolderMatch) {
nodeToTest = node.compressionStartParent ?? node;
}
const immediateParent = nodeToTest.parent();
if (immediateParent instanceof FolderMatchWorkspaceRoot || immediateParent instanceof FolderMatchNoRoot) {
if (viewer.hasElement(node)) {
viewer.collapse(node, true);

View file

@ -95,6 +95,7 @@ export class FolderMatchRenderer extends Disposable implements ICompressibleTree
renderCompressedElements(node: ITreeNode<ICompressedTreeNode<FolderMatch>, any>, index: number, templateData: IFolderMatchTemplate, height: number | undefined): void {
const compressed = node.element;
const folder = compressed.elements[compressed.elements.length - 1];
folder.compressionStartParent = compressed.elements[0];
const label = compressed.elements.map(e => e.name());
if (folder.resource) {
@ -134,6 +135,7 @@ export class FolderMatchRenderer extends Disposable implements ICompressibleTree
renderElement(node: ITreeNode<FolderMatch, any>, index: number, templateData: IFolderMatchTemplate): void {
const folderMatch = node.element;
folderMatch.compressionStartParent = undefined;
if (folderMatch.resource) {
const workspaceFolder = this.contextService.getWorkspaceFolder(folderMatch.resource);
if (workspaceFolder && isEqual(workspaceFolder.uri, folderMatch.resource)) {

View file

@ -492,6 +492,10 @@ export class FolderMatch extends Disposable {
protected _unDisposedFileMatches: ResourceMap<FileMatch>;
protected _unDisposedFolderMatches: ResourceMap<FolderMatchWithResource>;
private _replacingAll: boolean = false;
// if this is compressed in a node with other FolderMatches, then this is set to the parent where compression starts
public compressionStartParent: FolderMatch | undefined;
constructor(
protected _resource: URI | null,
private _id: string,