Skip to content

Commit dbbf526

Browse files
authored
add trace logs for search parent debug (microsoft#165095)
* add trace logs for search parent debug
1 parent a46fb19 commit dbbf526

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
2424
import { IFileService, IFileStatWithPartialMetadata } from 'vs/platform/files/common/files';
2525
import { createDecorator, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
2626
import { ILabelService } from 'vs/platform/label/common/label';
27+
import { ILogService, LogLevel } from 'vs/platform/log/common/log';
2728
import { IProgress, IProgressStep } from 'vs/platform/progress/common/progress';
2829
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
2930
import { minimapFindMatch, overviewRulerFindMatchForeground } from 'vs/platform/theme/common/colorRegistry';
@@ -851,7 +852,8 @@ export class FolderMatchWorkspaceRoot extends FolderMatchWithResource {
851852
@IReplaceService replaceService: IReplaceService,
852853
@IInstantiationService instantiationService: IInstantiationService,
853854
@ILabelService labelService: ILabelService,
854-
@IUriIdentityService uriIdentityService: IUriIdentityService
855+
@IUriIdentityService uriIdentityService: IUriIdentityService,
856+
@ILogService private readonly _logService: ILogService,
855857
) {
856858
super(_resource, _id, _index, _query, _parent, _searchModel, null, replaceService, instantiationService, labelService, uriIdentityService);
857859
}
@@ -881,14 +883,22 @@ export class FolderMatchWorkspaceRoot extends FolderMatchWithResource {
881883
const fileMatchParentParts: URI[] = [];
882884
let uri = this.uriParent(rawFileMatch.resource);
883885

886+
const debug: string[] = ['[search model building]'];
884887
while (!this.uriEquals(this.resource, uri)) {
885888
fileMatchParentParts.unshift(uri);
886889
const prevUri = uri;
887890
uri = this.uriParent(uri);
891+
if (this._logService.getLevel() === LogLevel.Trace) {
892+
debug.push(`current uri parent ${uri} comparing with ${prevUri}`);
893+
}
888894
if (this.uriEquals(prevUri, uri)) {
895+
this._logService.trace(debug.join('\n\n'));
889896
throw Error(`${rawFileMatch.resource} is not correctly configured as a child of its ${this.resource}`);
890897
}
891898
}
899+
if (this._logService.getLevel() === LogLevel.Trace) {
900+
this._logService.trace(debug.join('\n\n'));
901+
}
892902

893903
const root = this.closestRoot ?? this;
894904
let parent: FolderMatch = this;

src/vs/workbench/contrib/search/test/browser/searchViewlet.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { TestConfigurationService } from 'vs/platform/configuration/test/common/
1414
import { FileService } from 'vs/platform/files/common/fileService';
1515
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
1616
import { ILabelService } from 'vs/platform/label/common/label';
17-
import { NullLogService } from 'vs/platform/log/common/log';
17+
import { ILogService, NullLogService } from 'vs/platform/log/common/log';
1818
import { IThemeService } from 'vs/platform/theme/common/themeService';
1919
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
2020
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
@@ -36,6 +36,7 @@ suite('Search - Viewlet', () => {
3636
instantiation.set(IWorkspaceContextService, new TestContextService(TestWorkspace));
3737
instantiation.stub(IUriIdentityService, new UriIdentityService(new FileService(new NullLogService())));
3838
instantiation.stub(ILabelService, new MockLabelService());
39+
instantiation.stub(ILogService, new NullLogService());
3940
});
4041

4142
test('Data Source', function () {

src/vs/workbench/contrib/search/test/common/searchModel.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { SearchModel } from 'vs/workbench/contrib/search/common/searchModel';
2020
import { IThemeService } from 'vs/platform/theme/common/themeService';
2121
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
2222
import { FileService } from 'vs/platform/files/common/fileService';
23-
import { NullLogService } from 'vs/platform/log/common/log';
23+
import { ILogService, NullLogService } from 'vs/platform/log/common/log';
2424
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
2525
import { UriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentityService';
2626
import { isWindows } from 'vs/base/common/platform';
@@ -78,6 +78,7 @@ suite('SearchModel', () => {
7878
instantiationService.stub(ISearchService, {});
7979
instantiationService.stub(ISearchService, 'textSearch', Promise.resolve({ results: [] }));
8080
instantiationService.stub(IUriIdentityService, new UriIdentityService(new FileService(new NullLogService())));
81+
instantiationService.stub(ILogService, new NullLogService());
8182

8283
const config = new TestConfigurationService();
8384
config.setUserConfiguration('search', { searchOnType: true });

src/vs/workbench/contrib/search/test/common/searchResult.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService
2121
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
2222
import { UriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentityService';
2323
import { FileService } from 'vs/platform/files/common/fileService';
24-
import { NullLogService } from 'vs/platform/log/common/log';
24+
import { ILogService, NullLogService } from 'vs/platform/log/common/log';
2525
import { ILabelService } from 'vs/platform/label/common/label';
2626
import { MockLabelService } from 'vs/workbench/services/label/test/common/mockLabelService';
2727
import { isWindows } from 'vs/base/common/platform';
@@ -40,6 +40,7 @@ suite('SearchResult', () => {
4040
instantiationService.stubPromise(IReplaceService, {});
4141
instantiationService.stub(IReplaceService, 'replace', () => Promise.resolve(null));
4242
instantiationService.stub(ILabelService, new MockLabelService());
43+
instantiationService.stub(ILogService, new NullLogService());
4344
});
4445

4546
test('Line Match', function () {

0 commit comments

Comments
 (0)