From c0ac30984b05536489db7f99a070e6b6b28b57ab Mon Sep 17 00:00:00 2001 From: andreamah Date: Mon, 31 Oct 2022 13:26:46 -0700 Subject: [PATCH 1/4] add trace logs for search parent debug --- src/vs/workbench/contrib/search/common/searchModel.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/search/common/searchModel.ts b/src/vs/workbench/contrib/search/common/searchModel.ts index d7a8ce87201bd..e00800bc430d9 100644 --- a/src/vs/workbench/contrib/search/common/searchModel.ts +++ b/src/vs/workbench/contrib/search/common/searchModel.ts @@ -24,6 +24,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur import { IFileService, IFileStatWithPartialMetadata } from 'vs/platform/files/common/files'; import { createDecorator, IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { ILabelService } from 'vs/platform/label/common/label'; +import { ILogService } from 'vs/platform/log/common/log'; import { IProgress, IProgressStep } from 'vs/platform/progress/common/progress'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { minimapFindMatch, overviewRulerFindMatchForeground } from 'vs/platform/theme/common/colorRegistry'; @@ -851,7 +852,8 @@ export class FolderMatchWorkspaceRoot extends FolderMatchWithResource { @IReplaceService replaceService: IReplaceService, @IInstantiationService instantiationService: IInstantiationService, @ILabelService labelService: ILabelService, - @IUriIdentityService uriIdentityService: IUriIdentityService + @IUriIdentityService uriIdentityService: IUriIdentityService, + @ILogService private readonly _logService: ILogService, ) { super(_resource, _id, _index, _query, _parent, _searchModel, null, replaceService, instantiationService, labelService, uriIdentityService); } @@ -881,14 +883,17 @@ export class FolderMatchWorkspaceRoot extends FolderMatchWithResource { const fileMatchParentParts: URI[] = []; let uri = this.uriParent(rawFileMatch.resource); + let debugStr = ''; while (!this.uriEquals(this.resource, uri)) { fileMatchParentParts.unshift(uri); const prevUri = uri; uri = this.uriParent(uri); + debugStr += `current uri parent ${uri} comparing with ${prevUri}\n\n`; if (this.uriEquals(prevUri, uri)) { throw Error(`${rawFileMatch.resource} is not correctly configured as a child of its ${this.resource}`); } } + this._logService.trace(debugStr); const root = this.closestRoot ?? this; let parent: FolderMatch = this; From 79492ad5dc54411261d8527ec8c6a1b2a6cd938a Mon Sep 17 00:00:00 2001 From: andreamah Date: Mon, 31 Oct 2022 14:08:33 -0700 Subject: [PATCH 2/4] fix tests --- src/vs/workbench/contrib/search/common/searchModel.ts | 2 +- .../contrib/search/test/browser/searchViewlet.test.ts | 3 ++- .../workbench/contrib/search/test/common/searchModel.test.ts | 3 ++- .../workbench/contrib/search/test/common/searchResult.test.ts | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/vs/workbench/contrib/search/common/searchModel.ts b/src/vs/workbench/contrib/search/common/searchModel.ts index e00800bc430d9..e4fd11cf4c838 100644 --- a/src/vs/workbench/contrib/search/common/searchModel.ts +++ b/src/vs/workbench/contrib/search/common/searchModel.ts @@ -893,7 +893,7 @@ export class FolderMatchWorkspaceRoot extends FolderMatchWithResource { throw Error(`${rawFileMatch.resource} is not correctly configured as a child of its ${this.resource}`); } } - this._logService.trace(debugStr); + this._logService.trace('[search model building] ' + debugStr); const root = this.closestRoot ?? this; let parent: FolderMatch = this; diff --git a/src/vs/workbench/contrib/search/test/browser/searchViewlet.test.ts b/src/vs/workbench/contrib/search/test/browser/searchViewlet.test.ts index d003bb48d856b..a51ea982326dd 100644 --- a/src/vs/workbench/contrib/search/test/browser/searchViewlet.test.ts +++ b/src/vs/workbench/contrib/search/test/browser/searchViewlet.test.ts @@ -14,7 +14,7 @@ import { TestConfigurationService } from 'vs/platform/configuration/test/common/ import { FileService } from 'vs/platform/files/common/fileService'; import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock'; import { ILabelService } from 'vs/platform/label/common/label'; -import { NullLogService } from 'vs/platform/log/common/log'; +import { ILogService, NullLogService } from 'vs/platform/log/common/log'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService'; import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity'; @@ -36,6 +36,7 @@ suite('Search - Viewlet', () => { instantiation.set(IWorkspaceContextService, new TestContextService(TestWorkspace)); instantiation.stub(IUriIdentityService, new UriIdentityService(new FileService(new NullLogService()))); instantiation.stub(ILabelService, new MockLabelService()); + instantiation.stub(ILogService, new NullLogService()); }); test('Data Source', function () { diff --git a/src/vs/workbench/contrib/search/test/common/searchModel.test.ts b/src/vs/workbench/contrib/search/test/common/searchModel.test.ts index 1bd22a3466a8e..c62b157915d93 100644 --- a/src/vs/workbench/contrib/search/test/common/searchModel.test.ts +++ b/src/vs/workbench/contrib/search/test/common/searchModel.test.ts @@ -20,7 +20,7 @@ import { SearchModel } from 'vs/workbench/contrib/search/common/searchModel'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService'; import { FileService } from 'vs/platform/files/common/fileService'; -import { NullLogService } from 'vs/platform/log/common/log'; +import { ILogService, NullLogService } from 'vs/platform/log/common/log'; import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity'; import { UriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentityService'; import { isWindows } from 'vs/base/common/platform'; @@ -78,6 +78,7 @@ suite('SearchModel', () => { instantiationService.stub(ISearchService, {}); instantiationService.stub(ISearchService, 'textSearch', Promise.resolve({ results: [] })); instantiationService.stub(IUriIdentityService, new UriIdentityService(new FileService(new NullLogService()))); + instantiationService.stub(ILogService, new NullLogService()); const config = new TestConfigurationService(); config.setUserConfiguration('search', { searchOnType: true }); diff --git a/src/vs/workbench/contrib/search/test/common/searchResult.test.ts b/src/vs/workbench/contrib/search/test/common/searchResult.test.ts index ed10f20a80bfc..b7c72c0c44c03 100644 --- a/src/vs/workbench/contrib/search/test/common/searchResult.test.ts +++ b/src/vs/workbench/contrib/search/test/common/searchResult.test.ts @@ -21,7 +21,7 @@ import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity'; import { UriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentityService'; import { FileService } from 'vs/platform/files/common/fileService'; -import { NullLogService } from 'vs/platform/log/common/log'; +import { ILogService, NullLogService } from 'vs/platform/log/common/log'; import { ILabelService } from 'vs/platform/label/common/label'; import { MockLabelService } from 'vs/workbench/services/label/test/common/mockLabelService'; import { isWindows } from 'vs/base/common/platform'; @@ -40,6 +40,7 @@ suite('SearchResult', () => { instantiationService.stubPromise(IReplaceService, {}); instantiationService.stub(IReplaceService, 'replace', () => Promise.resolve(null)); instantiationService.stub(ILabelService, new MockLabelService()); + instantiationService.stub(ILogService, new NullLogService()); }); test('Line Match', function () { From ed323940adb827b1d124f7ee8451b29d48de73f9 Mon Sep 17 00:00:00 2001 From: andreamah Date: Mon, 31 Oct 2022 14:30:36 -0700 Subject: [PATCH 3/4] add trace in the case where it throws --- src/vs/workbench/contrib/search/common/searchModel.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/search/common/searchModel.ts b/src/vs/workbench/contrib/search/common/searchModel.ts index e4fd11cf4c838..9951e2cd0dff1 100644 --- a/src/vs/workbench/contrib/search/common/searchModel.ts +++ b/src/vs/workbench/contrib/search/common/searchModel.ts @@ -890,10 +890,11 @@ export class FolderMatchWorkspaceRoot extends FolderMatchWithResource { uri = this.uriParent(uri); debugStr += `current uri parent ${uri} comparing with ${prevUri}\n\n`; if (this.uriEquals(prevUri, uri)) { + this._logService.trace('[search model building - failed] ' + debugStr); throw Error(`${rawFileMatch.resource} is not correctly configured as a child of its ${this.resource}`); } } - this._logService.trace('[search model building] ' + debugStr); + this._logService.trace('[search model building - success] ' + debugStr); const root = this.closestRoot ?? this; let parent: FolderMatch = this; From 04377c5b90b6c79c37c479f9463a4d7b25a76785 Mon Sep 17 00:00:00 2001 From: andreamah Date: Mon, 31 Oct 2022 14:48:15 -0700 Subject: [PATCH 4/4] change to concatenate when actually on trace --- .../workbench/contrib/search/common/searchModel.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/vs/workbench/contrib/search/common/searchModel.ts b/src/vs/workbench/contrib/search/common/searchModel.ts index 9951e2cd0dff1..f5d7b7b8bd007 100644 --- a/src/vs/workbench/contrib/search/common/searchModel.ts +++ b/src/vs/workbench/contrib/search/common/searchModel.ts @@ -24,7 +24,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur import { IFileService, IFileStatWithPartialMetadata } from 'vs/platform/files/common/files'; import { createDecorator, IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { ILabelService } from 'vs/platform/label/common/label'; -import { ILogService } from 'vs/platform/log/common/log'; +import { ILogService, LogLevel } from 'vs/platform/log/common/log'; import { IProgress, IProgressStep } from 'vs/platform/progress/common/progress'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { minimapFindMatch, overviewRulerFindMatchForeground } from 'vs/platform/theme/common/colorRegistry'; @@ -883,18 +883,22 @@ export class FolderMatchWorkspaceRoot extends FolderMatchWithResource { const fileMatchParentParts: URI[] = []; let uri = this.uriParent(rawFileMatch.resource); - let debugStr = ''; + const debug: string[] = ['[search model building]']; while (!this.uriEquals(this.resource, uri)) { fileMatchParentParts.unshift(uri); const prevUri = uri; uri = this.uriParent(uri); - debugStr += `current uri parent ${uri} comparing with ${prevUri}\n\n`; + if (this._logService.getLevel() === LogLevel.Trace) { + debug.push(`current uri parent ${uri} comparing with ${prevUri}`); + } if (this.uriEquals(prevUri, uri)) { - this._logService.trace('[search model building - failed] ' + debugStr); + this._logService.trace(debug.join('\n\n')); throw Error(`${rawFileMatch.resource} is not correctly configured as a child of its ${this.resource}`); } } - this._logService.trace('[search model building - success] ' + debugStr); + if (this._logService.getLevel() === LogLevel.Trace) { + this._logService.trace(debug.join('\n\n')); + } const root = this.closestRoot ?? this; let parent: FolderMatch = this;