diff --git a/src/server/features/fileConfigurationManager.ts b/src/server/features/fileConfigurationManager.ts index 1f93a3b..8ea8770 100644 --- a/src/server/features/fileConfigurationManager.ts +++ b/src/server/features/fileConfigurationManager.ts @@ -148,6 +148,7 @@ export default class FileConfigurationManager { disableSuggestions: !config.get('suggest.enabled', true), importModuleSpecifierPreference: getImportModuleSpecifier(config) as any, quotePreference: config.get<'single' | 'double'>('preferences.quoteStyle', 'single'), + allowRenameOfImportPath: true, allowTextChangesInNewFiles: true, } } diff --git a/src/server/typescriptServiceClient.ts b/src/server/typescriptServiceClient.ts index 25175c9..b533ec4 100644 --- a/src/server/typescriptServiceClient.ts +++ b/src/server/typescriptServiceClient.ts @@ -793,8 +793,16 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient public getProjectRootPath(uri: string): string { let u = Uri.parse(uri) - if (u.scheme != 'file') return workspace.cwd - if (u.fsPath.startsWith(workspace.root) && workspace.root != os.homedir()) return workspace.root + let { cwd } = workspace + if (u.scheme != 'file') return cwd + if (u.fsPath.startsWith(cwd) && cwd != os.homedir()) { + let files = fs.readdirSync(cwd) + if (files.indexOf('tsconfig.json') !== -1 + || files.indexOf('jsconfig.json') !== -1 + || files.indexOf('package.json') !== -1) { + return cwd + } + } let res = findUp.sync(['tsconfig.json', 'jsconfig.json'], { cwd: path.dirname(u.fsPath) }) return res ? path.dirname(res) : workspace.cwd }