Skip to content

Commit fa37b61

Browse files
authored
search: fix resources with trailing slash (microsoft#187106)
* search resources with trailing slash in root
1 parent 2f2bc05 commit fa37b61

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/vs/workbench/contrib/search/browser/searchModel.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,18 +1275,26 @@ export class FolderMatch extends Disposable {
12751275

12761276
export class FolderMatchWithResource extends FolderMatch {
12771277

1278+
protected _normalizedResource: Lazy<URI>;
1279+
12781280
constructor(_resource: URI, _id: string, _index: number, _query: ITextQuery, _parent: SearchResult | FolderMatch, _searchModel: SearchModel, _closestRoot: FolderMatchWorkspaceRoot | null,
12791281
@IReplaceService replaceService: IReplaceService,
12801282
@IInstantiationService instantiationService: IInstantiationService,
12811283
@ILabelService labelService: ILabelService,
12821284
@IUriIdentityService uriIdentityService: IUriIdentityService
12831285
) {
12841286
super(_resource, _id, _index, _query, _parent, _searchModel, _closestRoot, replaceService, instantiationService, labelService, uriIdentityService);
1287+
this._normalizedResource = new Lazy(() => this.uriIdentityService.extUri.removeTrailingPathSeparator(this.uriIdentityService.extUri.normalizePath(
1288+
this.resource)));
12851289
}
12861290

12871291
override get resource(): URI {
12881292
return this._resource!;
12891293
}
1294+
1295+
get normalizedResource(): URI {
1296+
return this._normalizedResource.value;
1297+
}
12901298
}
12911299

12921300
/**
@@ -1334,15 +1342,14 @@ export class FolderMatchWorkspaceRoot extends FolderMatchWithResource {
13341342
}
13351343

13361344
const fileMatchParentParts: URI[] = [];
1337-
const normalizedResource = this.uriIdentityService.extUri.normalizePath(this.resource);
13381345
let uri = this.normalizedUriParent(rawFileMatch.resource);
13391346

1340-
while (!this.uriEquals(normalizedResource, uri)) {
1347+
while (!this.uriEquals(this.normalizedResource, uri)) {
13411348
fileMatchParentParts.unshift(uri);
13421349
const prevUri = uri;
1343-
uri = this.normalizedUriParent(uri);
1350+
uri = this.uriIdentityService.extUri.removeTrailingPathSeparator(this.normalizedUriParent(uri));
13441351
if (this.uriEquals(prevUri, uri)) {
1345-
throw Error(`${rawFileMatch.resource} is not correctly configured as a child of ${normalizedResource}`);
1352+
throw Error(`${rawFileMatch.resource} is not correctly configured as a child of ${this.normalizedResource}`);
13461353
}
13471354
}
13481355

0 commit comments

Comments
 (0)