mirror of
https://github.com/microsoft/pyright.git
synced 2024-09-11 07:55:56 +03:00
Don't use Uri.Empty for default workspace. (#7654)
* Don't use Uri.Empty for default workspace. * addressed PR feedback
This commit is contained in:
parent
69ded75d4b
commit
a8399d3933
@ -518,7 +518,7 @@ export class AnalyzerService {
|
||||
? optionRoot
|
||||
: isString(optionRoot)
|
||||
? Uri.file(optionRoot, this.serviceProvider, /* checkRelative */ true)
|
||||
: Uri.empty();
|
||||
: Uri.defaultWorkspace(this.serviceProvider);
|
||||
|
||||
const executionRoot = this.fs.realCasePath(executionRootUri);
|
||||
let projectRoot = executionRoot;
|
||||
|
@ -8,15 +8,15 @@
|
||||
|
||||
import { URI, Utils } from 'vscode-uri';
|
||||
import { CaseSensitivityDetector } from '../caseSensitivityDetector';
|
||||
import { isArray } from '../core';
|
||||
import { combinePaths, isRootedDiskPath, normalizeSlashes } from '../pathUtils';
|
||||
import { ServiceKeys } from '../serviceKeys';
|
||||
import { ServiceKey } from '../serviceProvider';
|
||||
import { JsonObjType } from './baseUri';
|
||||
import { ConstantUri } from './constantUri';
|
||||
import { EmptyUri } from './emptyUri';
|
||||
import { FileUri, FileUriSchema } from './fileUri';
|
||||
import { WebUri } from './webUri';
|
||||
import { EmptyUri } from './emptyUri';
|
||||
import { JsonObjType } from './baseUri';
|
||||
import { isArray } from '../core';
|
||||
import { ServiceKeys } from '../serviceKeys';
|
||||
import { ConstantUri } from './constantUri';
|
||||
|
||||
export const enum UriKinds {
|
||||
file,
|
||||
@ -234,6 +234,13 @@ export namespace Uri {
|
||||
return EmptyUri.instance;
|
||||
}
|
||||
|
||||
export function defaultWorkspace(serviceProvider: IServiceProvider): Uri;
|
||||
export function defaultWorkspace(caseSensitivityDetector: CaseSensitivityDetector): Uri;
|
||||
export function defaultWorkspace(arg: IServiceProvider | CaseSensitivityDetector): Uri {
|
||||
arg = CaseSensitivityDetector.is(arg) ? arg : arg.get(ServiceKeys.caseSensitivityDetector);
|
||||
return Uri.file('/<default workspace root>/', arg);
|
||||
}
|
||||
|
||||
export function fromJsonObj(jsonObj: JsonObjType) {
|
||||
if (isArray<SerializedType>(jsonObj)) {
|
||||
// Currently only file uri supports SerializedType.
|
||||
|
@ -355,3 +355,19 @@ test('verify can serialize config options', () => {
|
||||
assert.deepEqual(config, deserialized);
|
||||
assert.ok(deserialized.findExecEnvironment(UriEx.file('foo/bar.py')));
|
||||
});
|
||||
|
||||
test('extra paths on undefined execution root/default workspace', () => {
|
||||
const nullConsole = new NullConsole();
|
||||
const service = createAnalyzer(nullConsole);
|
||||
const commandLineOptions = new CommandLineOptions(undefined, /* fromVsCodeExtension */ false);
|
||||
commandLineOptions.extraPaths = ['/extraPaths'];
|
||||
|
||||
service.setOptions(commandLineOptions);
|
||||
const configOptions = service.test_getConfigOptions(commandLineOptions);
|
||||
|
||||
const expectedExtraPaths = [Uri.file('/extraPaths', service.serviceProvider)];
|
||||
assert.deepStrictEqual(
|
||||
configOptions.defaultExtraPaths?.map((u) => u.getFilePath()),
|
||||
expectedExtraPaths.map((u) => u.getFilePath())
|
||||
);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user