Skip to content

Commit

Permalink
fix: issue cause by commit d1a7fa7 (#1040)
Browse files Browse the repository at this point in the history
See [fix: Adjust the way glob roots are calculated]
(d1a7fa7#commitcomment-47719278)
  • Loading branch information
Jason3S committed Mar 5, 2021
1 parent 43b0c6d commit da9ca51
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/cspell-lib/src/Settings/CSpellSettingsServer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ describe('Validate Glob resolution', () => {

test('normalized settings', () => {
expect(sampleSettings).not.toEqual(sampleSettingsV1);
expect(sampleSettings.globRoot).toEqual(sampleSettingsV1.globRoot);
expect(sampleSettings.globRoot).not.toEqual(sampleSettingsV1.globRoot);
expect(sampleSettings.globRoot).toBe(__dirname);
expect(sampleSettingsV1.globRoot).toContain(process.cwd());
expect(sampleSettings.ignorePaths).toEqual(
Expand All @@ -339,7 +339,7 @@ describe('Validate Glob resolution', () => {
const settingsV1 = normalizeSettings(rawSampleSettingsV1, __filename);

expect(settingsV).toEqual(sampleSettings);
expect(settingsV1).toEqual(sampleSettingsV1);
expect(settingsV1).not.toEqual(sampleSettingsV1);

delete settingsV1.version;
expect(settingsV1).toEqual(sampleSettings);
Expand Down
5 changes: 1 addition & 4 deletions packages/cspell-lib/src/Settings/CSpellSettingsServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ function mergeSources(left: CSpellSettings, right: CSpellSettings): Source {
};
}

function max<T>(a: undefined, b: undefined): undefined;
function max(a: undefined, b: undefined): undefined;
function max<T>(a: T, b: undefined): T;
function max<T>(a: undefined, b: T): T;
function max<T>(a: T | undefined, b: T | undefined): T | undefined;
Expand Down Expand Up @@ -633,9 +633,6 @@ function resolveGlobRoot(settings: CSpellSettings, pathToSettingsFile: string):
settings.globRoot ??
(settings.version === '0.1' || (envGlobRoot && !settings.version) ? defaultGlobRoot : settingsFileDir);
const globRoot = path.resolve(settingsFileDir, rawRoot.replace('${cwd}', cwd));
if (settings.globRoot) return globRoot;
if (settingsFileDir.startsWith(globRoot)) return settingsFileDir;
if (globRoot.startsWith(settingsFileDir)) return settingsFileDir;
return globRoot;
}

Expand Down

0 comments on commit da9ca51

Please sign in to comment.