@@ -42,7 +42,8 @@ import { localizedStringCount, lookupString } from '../nativeStrings';
42
42
import * as telemetry from '../telemetry' ;
43
43
import { TestHook , getTestHook } from '../testHook' ;
44
44
import {
45
- CodeAnalysisDiagnosticIdentifiersAndUri , RegisterCodeAnalysisNotifications ,
45
+ CodeAnalysisDiagnosticIdentifiersAndUri ,
46
+ RegisterCodeAnalysisNotifications ,
46
47
RemoveCodeAnalysisProblemsParams ,
47
48
removeAllCodeAnalysisProblems ,
48
49
removeCodeAnalysisProblems
@@ -97,6 +98,7 @@ interface ConfigStateReceived {
97
98
let displayedSelectCompiler : boolean = false ;
98
99
let secondPromptCounter : number = 0 ;
99
100
let scanForCompilersDone : boolean = false ;
101
+ let workspaceHash : string = "" ;
100
102
101
103
let workspaceDisposables : vscode . Disposable [ ] = [ ] ;
102
104
export let workspaceReferences : refs . ReferencesManager ;
@@ -539,7 +541,9 @@ export interface TextDocumentWillSaveParams {
539
541
interface InitializationOptions {
540
542
packageVersion : string ;
541
543
extensionPath : string ;
542
- storagePath : string ;
544
+ cacheStoragePath : string ;
545
+ workspaceStoragePath : string ;
546
+ databaseStoragePath : string ;
543
547
freeMemory : number ;
544
548
vcpkgRoot : string ;
545
549
intelliSenseCacheDisabled : boolean ;
@@ -821,7 +825,7 @@ export class DefaultClient implements Client {
821
825
private rootPathFileWatcher ?: vscode . FileSystemWatcher ;
822
826
private rootFolder ?: vscode . WorkspaceFolder ;
823
827
private rootRealPath : string ;
824
- private storagePath : string ;
828
+ private workspaceStoragePath : string ;
825
829
private trackedDocuments = new Set < vscode . TextDocument > ( ) ;
826
830
private isSupported : boolean = true ;
827
831
private inactiveRegionsDecorations = new Map < string , DecorationRangesPair > ( ) ;
@@ -916,7 +920,7 @@ export class DefaultClient implements Client {
916
920
public get AdditionalEnvironment ( ) : { [ key : string ] : string | string [ ] } {
917
921
return {
918
922
workspaceFolderBasename : this . Name ,
919
- workspaceStorage : this . storagePath ,
923
+ workspaceStorage : this . workspaceStoragePath ,
920
924
execPath : process . execPath ,
921
925
pathSeparator : ( os . platform ( ) === 'win32' ) ? "\\" : "/"
922
926
} ;
@@ -1285,21 +1289,17 @@ export class DefaultClient implements Client {
1285
1289
this . rootFolder = workspaceFolder ;
1286
1290
this . rootRealPath = this . RootPath ? fs . existsSync ( this . RootPath ) ? fs . realpathSync ( this . RootPath ) : this . RootPath : "" ;
1287
1291
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" ) : "" ;
1294
1297
}
1295
1298
1296
- if ( ! storagePath ) {
1297
- storagePath = this . RootPath ? path . join ( this . RootPath , "/.vscode" ) : "" ;
1298
- }
1299
1299
if ( 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 ) ) ;
1301
1301
}
1302
- this . storagePath = storagePath ;
1302
+
1303
1303
const rootUri : vscode . Uri | undefined = this . RootUri ;
1304
1304
this . settingsTracker = new SettingsTracker ( rootUri ) ;
1305
1305
@@ -1622,10 +1622,16 @@ export class DefaultClient implements Client {
1622
1622
currentCaseSensitiveFileSupport . Value = workspaceSettings . caseSensitiveFileSupport ;
1623
1623
}
1624
1624
1625
+ const cacheStoragePath : string = util . getCacheStoragePath ( ) ;
1626
+ const databaseStoragePath : string = ( cacheStoragePath . length > 0 ) && ( workspaceHash . length > 0 ) ?
1627
+ path . join ( cacheStoragePath , workspaceHash ) : "" ;
1628
+
1625
1629
const initializationOptions : InitializationOptions = {
1626
1630
packageVersion : util . packageJson . version ,
1627
1631
extensionPath : util . extensionPath ,
1628
- storagePath : this . storagePath ,
1632
+ databaseStoragePath : databaseStoragePath ,
1633
+ workspaceStoragePath : this . workspaceStoragePath ,
1634
+ cacheStoragePath : cacheStoragePath ,
1629
1635
freeMemory : Math . floor ( os . freemem ( ) / 1048576 ) ,
1630
1636
vcpkgRoot : util . getVcpkgRoot ( ) ,
1631
1637
intelliSenseCacheDisabled : intelliSenseCacheDisabled ,
@@ -2029,7 +2035,7 @@ export class DefaultClient implements Client {
2029
2035
2030
2036
const response : QueryTranslationUnitSourceResult = await this . languageClient . sendRequest ( QueryTranslationUnitSourceRequest , params ) ;
2031
2037
if ( ! 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.
2033
2039
onFinished ( ) ;
2034
2040
DefaultClient . isStarted . resolve ( ) ;
2035
2041
return ;
0 commit comments