Skip to content

Commit a1e5eeb

Browse files
committed
merge with origin/master
2 parents 91b0eea + 01c1bdb commit a1e5eeb

3 files changed

Lines changed: 15 additions & 8 deletions

File tree

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,7 @@ namespace ts {
13151315
projectService.openClientFile(file1.path, `var x = 1;`);
13161316
project.updateGraph();
13171317

1318-
const quickInfo = project.languageService.getQuickInfoAtPosition(file1.path, 4);
1318+
const quickInfo = project.getLanguageService().getQuickInfoAtPosition(file1.path, 4);
13191319
assert.equal(quickInfo.kind, ScriptElementKind.variableElement);
13201320

13211321
projectService.closeClientFile(file1.path);

src/server/editorServices.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ namespace ts.server {
135135
/**
136136
* Container of all known scripts
137137
*/
138-
private readonly filenameToScriptInfo = createNormalizedPathMap<ScriptInfo>();
138+
private readonly filenameToScriptInfo = createFileMap<ScriptInfo>();
139139
/**
140140
* maps external project file name to list of config files that were the part of this project
141141
*/
@@ -165,12 +165,15 @@ namespace ts.server {
165165

166166
private changedFiles: ScriptInfo[];
167167

168+
private toCanonicalFileName: (f: string) => string;
169+
168170
constructor(public readonly host: ServerHost,
169171
public readonly logger: Logger,
170172
public readonly cancellationToken: HostCancellationToken,
171173
private readonly useSingleInferredProject: boolean,
172174
private readonly eventHandler?: ProjectServiceEventHandler) {
173175

176+
this.toCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames);
174177
this.directoryWatchers = new DirectoryWatchers(this);
175178
this.throttledOperations = new ThrottledOperations(host);
176179
// ts.disableIncrementalParsing = true;
@@ -300,7 +303,7 @@ namespace ts.server {
300303
// TODO: handle isOpen = true case
301304

302305
if (!info.isOpen) {
303-
this.filenameToScriptInfo.remove(info.fileName);
306+
this.filenameToScriptInfo.remove(info.path);
304307

305308
// capture list of projects since detachAllProjects will wipe out original list
306309
const containingProjects = info.containingProjects.slice();
@@ -504,7 +507,7 @@ namespace ts.server {
504507
}
505508
if (info.containingProjects.length === 0) {
506509
// if there are not projects that include this script info - delete it
507-
this.filenameToScriptInfo.remove(info.fileName);
510+
this.filenameToScriptInfo.remove(info.path);
508511
}
509512
}
510513

@@ -878,9 +881,9 @@ namespace ts.server {
878881
if (content !== undefined) {
879882
info = new ScriptInfo(this.host, fileName, content, scriptKind, openedByClient, hasMixedContent);
880883
info.setFormatOptions(toEditorSettings(this.getFormatCodeOptions()));
881-
this.filenameToScriptInfo.set(fileName, info);
884+
// do not watch files with mixed content - server doesn't know how to interpret it
885+
this.filenameToScriptInfo.set(info.path, info);
882886
if (!info.isOpen && !hasMixedContent) {
883-
// do not watch files with mixed content - server doesn't know how to interpret it
884887
info.setWatcher(this.host.watchFile(fileName, _ => this.onSourceFileChanged(fileName)));
885888
}
886889
}
@@ -897,7 +900,7 @@ namespace ts.server {
897900
}
898901

899902
getScriptInfoForNormalizedPath(fileName: NormalizedPath) {
900-
return this.filenameToScriptInfo.get(fileName);
903+
return this.filenameToScriptInfo.get(normalizedPathToPath(fileName, this.host.getCurrentDirectory(), this.toCanonicalFileName));
901904
}
902905

903906
setHostConfiguration(args: protocol.ConfigureRequestArguments) {
@@ -1057,7 +1060,6 @@ namespace ts.server {
10571060
this.closeClientFile(file);
10581061
}
10591062
}
1060-
10611063
// if files were open or closed then explicitly refresh list of inferred projects
10621064
// otherwise if there were only changes in files - record changed files in `changedFiles` and defer the update
10631065
if (openFiles || closedFiles) {

src/server/utilities.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ namespace ts.server {
8282
return <NormalizedPath>normalizePath(fileName);
8383
}
8484

85+
export function normalizedPathToPath(normalizedPath: NormalizedPath, currentDirectory: string, getCanonicalFileName: (f: string) => string): Path {
86+
const f = isRootedDiskPath(normalizedPath) ? normalizedPath : getNormalizedAbsolutePath(normalizedPath, currentDirectory);
87+
return <Path>getCanonicalFileName(f);
88+
}
89+
8590
export function asNormalizedPath(fileName: string): NormalizedPath {
8691
return <NormalizedPath>fileName;
8792
}

0 commit comments

Comments
 (0)