@@ -42,7 +42,8 @@ import { localizedStringCount, lookupString } from '../nativeStrings';
4242import * as telemetry from '../telemetry' ;
4343import { TestHook , getTestHook } from '../testHook' ;
4444import {
45- CodeAnalysisDiagnosticIdentifiersAndUri , RegisterCodeAnalysisNotifications ,
45+ CodeAnalysisDiagnosticIdentifiersAndUri ,
46+ RegisterCodeAnalysisNotifications ,
4647RemoveCodeAnalysisProblemsParams ,
4748removeAllCodeAnalysisProblems ,
4849removeCodeAnalysisProblems
@@ -97,6 +98,7 @@ interface ConfigStateReceived {
9798let displayedSelectCompiler :boolean = false ;
9899let secondPromptCounter :number = 0 ;
99100let scanForCompilersDone :boolean = false ;
101+ let workspaceHash :string = "" ;
100102
101103let workspaceDisposables :vscode . Disposable [ ] = [ ] ;
102104export let workspaceReferences :refs . ReferencesManager ;
@@ -539,7 +541,9 @@ export interface TextDocumentWillSaveParams {
539541interface InitializationOptions {
540542packageVersion :string ;
541543extensionPath :string ;
542- storagePath :string ;
544+ cacheStoragePath :string ;
545+ workspaceStoragePath :string ;
546+ databaseStoragePath :string ;
543547freeMemory :number ;
544548vcpkgRoot :string ;
545549intelliSenseCacheDisabled :boolean ;
@@ -821,7 +825,7 @@ export class DefaultClient implements Client {
821825private rootPathFileWatcher ?:vscode . FileSystemWatcher ;
822826private rootFolder ?:vscode . WorkspaceFolder ;
823827private rootRealPath :string ;
824- private storagePath :string ;
828+ private workspaceStoragePath :string ;
825829private trackedDocuments = new Set < vscode . TextDocument > ( ) ;
826830private isSupported :boolean = true ;
827831private inactiveRegionsDecorations = new Map < string , DecorationRangesPair > ( ) ;
@@ -916,7 +920,7 @@ export class DefaultClient implements Client {
916920public get AdditionalEnvironment ( ) :{ [ key :string ] :string | string [ ] } {
917921return {
918922workspaceFolderBasename :this . Name ,
919- workspaceStorage :this . storagePath ,
923+ workspaceStorage :this . workspaceStoragePath ,
920924execPath :process . execPath ,
921925pathSeparator :( os . platform ( ) === 'win32' ) ?"\\" :"/"
922926} ;
@@ -1285,21 +1289,17 @@ export class DefaultClient implements Client {
12851289this . rootFolder = workspaceFolder ;
12861290this . rootRealPath = this . RootPath ?fs . existsSync ( this . RootPath ) ?fs . realpathSync ( this . RootPath ) :this . RootPath :"" ;
12871291
1288- let storagePath :string | undefined ;
1289- if ( util . extensionContext ) {
1290- const path :string | undefined = util . extensionContext . storageUri ?. fsPath ;
1291- if ( path ) {
1292- storagePath = path ;
1293- }
1292+ this . workspaceStoragePath = util . extensionContext ?. storageUri ?. fsPath ?? "" ;
1293+ if ( this . workspaceStoragePath . length > 0 ) {
1294+ workspaceHash = path . basename ( path . dirname ( this . workspaceStoragePath ) ) ;
1295+ } else {
1296+ this . workspaceStoragePath = this . RootPath ?path . join ( this . RootPath , ".vscode" ) :"" ;
12941297}
12951298
1296- if ( ! storagePath ) {
1297- storagePath = this . RootPath ?path . join ( this . RootPath , "/.vscode" ) :"" ;
1298- }
12991299if ( workspaceFolder && vscode . workspace . workspaceFolders && vscode . workspace . workspaceFolders . length > 1 ) {
1300- storagePath = path . join ( storagePath , util . getUniqueWorkspaceStorageName ( workspaceFolder ) ) ;
1300+ this . workspaceStoragePath = path . join ( this . workspaceStoragePath , util . getUniqueWorkspaceStorageName ( workspaceFolder ) ) ;
13011301}
1302- this . storagePath = storagePath ;
1302+
13031303const rootUri :vscode . Uri | undefined = this . RootUri ;
13041304this . settingsTracker = new SettingsTracker ( rootUri ) ;
13051305
@@ -1622,10 +1622,16 @@ export class DefaultClient implements Client {
16221622currentCaseSensitiveFileSupport . Value = workspaceSettings . caseSensitiveFileSupport ;
16231623}
16241624
1625+ const cacheStoragePath :string = util . getCacheStoragePath ( ) ;
1626+ const databaseStoragePath :string = ( cacheStoragePath . length > 0 ) && ( workspaceHash . length > 0 ) ?
1627+ path . join ( cacheStoragePath , workspaceHash ) :"" ;
1628+
16251629const initializationOptions :InitializationOptions = {
16261630packageVersion :util . packageJson . version ,
16271631extensionPath :util . extensionPath ,
1628- storagePath :this . storagePath ,
1632+ databaseStoragePath :databaseStoragePath ,
1633+ workspaceStoragePath :this . workspaceStoragePath ,
1634+ cacheStoragePath :cacheStoragePath ,
16291635freeMemory :Math . floor ( os . freemem ( ) / 1048576 ) ,
16301636vcpkgRoot :util . getVcpkgRoot ( ) ,
16311637intelliSenseCacheDisabled :intelliSenseCacheDisabled ,
@@ -2029,7 +2035,7 @@ export class DefaultClient implements Client {
20292035
20302036const response :QueryTranslationUnitSourceResult = await this . languageClient . sendRequest ( QueryTranslationUnitSourceRequest , params ) ;
20312037if ( ! response . candidates || response . candidates . length === 0 ) {
2032- // If we didn't receive any candidates, no configuration is needed.
2038+ // If we didn't receive any candidates, no configuration is needed.
20332039onFinished ( ) ;
20342040DefaultClient . isStarted . resolve ( ) ;
20352041return ;