Skip to content

Commit d08212a

Browse files
author
Kapil Borle
committed
Check psd1 extension before getting symbols
1 parent a1530a2 commit d08212a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/PowerShellEditorServices/Language/AstOperations.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,12 @@ static public IEnumerable<SymbolReference> FindSymbolsInDocument(Ast scriptAst,
209209
// }
210210
// else
211211
{
212-
// we don't have reliable access to the filename here
213-
// so we employ the following heuristic to check if the
214-
// contents are part of a psd1 file.
215-
if (IsPowerShellDataFile(scriptAst))
212+
// sometimes we don't have reliable access to the filename
213+
// so we employ heuristics to check if the contents are
214+
// part of a psd1 file.
215+
if ((scriptAst.Extent.File != null
216+
&& scriptAst.Extent.File.EndsWith(".psd1", StringComparison.OrdinalIgnoreCase))
217+
|| IsPowerShellDataFile(scriptAst))
216218
{
217219
var findHashtableSymbolsVisitor = new FindHashtabeSymbolsVisitor();
218220
scriptAst.Visit(findHashtableSymbolsVisitor);

0 commit comments

Comments
 (0)