Skip to content

Commit 5ba4f30

Browse files
committed
Fix unneccessary file read for workspace script files
1 parent 700d4f6 commit 5ba4f30

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/PowerShellEditorServices/Language/LanguageService.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using System.Linq;
1313
using System.Management.Automation;
1414
using System.Management.Automation.Language;
15+
using System.Runtime.InteropServices;
1516
using System.Threading;
1617
using System.Threading.Tasks;
1718

@@ -308,24 +309,23 @@ public async Task<FindReferencesResult> FindReferencesOfSymbol(
308309
await GetAliases();
309310

310311
// We want to look for references first in referenced files, hence we use ordered dictionary
311-
var fileMap = new OrderedDictionary(StringComparer.OrdinalIgnoreCase);
312+
// TODO: File system case-sensitivity is based on filesystem not OS, but OS is a much cheaper heuristic
313+
var fileMap = RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
314+
? new OrderedDictionary()
315+
: new OrderedDictionary(StringComparer.OrdinalIgnoreCase);
312316
foreach (ScriptFile file in referencedFiles)
313317
{
314318
fileMap.Add(file.FilePath, file);
315319
}
316320

317-
IEnumerable<string> allFiles = workspace.EnumeratePSFiles();
318-
foreach (string file in allFiles)
321+
foreach (string file in workspace.EnumeratePSFiles())
319322
{
320323
if (!fileMap.Contains(file))
321324
{
322325
ScriptFile scriptFile;
323326
try
324327
{
325-
scriptFile = new ScriptFile(
326-
file,
327-
clientFilePath: null,
328-
powerShellVersion: this.powerShellContext.LocalPowerShellVersion.Version);
328+
scriptFile = workspace.GetFile(file);
329329
}
330330
catch (IOException)
331331
{

0 commit comments

Comments
 (0)