Skip to content

Commit 7a10453

Browse files
authored
Merge pull request #364 from PowerShell/rkeithhill/add-completionitemkind-folder
Add CompletionItemKind.Folder.
2 parents f80abdc + 60200c9 commit 7a10453

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

src/PowerShellEditorServices.Protocol/LanguageServer/Completion.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@ public enum CompletionItemKind
4141
Snippet = 15,
4242
Color = 16,
4343
File = 17,
44-
Reference = 18
44+
Reference = 18,
45+
Folder = 19
4546
}
4647

4748
[DebuggerDisplay("NewText = {NewText}, Range = {Range.Start.Line}:{Range.Start.Character} - {Range.End.Line}:{Range.End.Character}")]
48-
public class TextEdit
49+
public class TextEdit
4950
{
5051
public Range Range { get; set; }
5152

src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1366,9 +1366,12 @@ private static CompletionItemKind MapCompletionKind(CompletionType completionTyp
13661366
case CompletionType.ParameterName:
13671367
return CompletionItemKind.Variable;
13681368

1369-
case CompletionType.Path:
1369+
case CompletionType.File:
13701370
return CompletionItemKind.File;
13711371

1372+
case CompletionType.Folder:
1373+
return CompletionItemKind.Folder;
1374+
13721375
default:
13731376
return CompletionItemKind.Text;
13741377
}

src/PowerShellEditorServices/Language/CompletionResults.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public sealed class CompletionResults
2020
#region Properties
2121

2222
/// <summary>
23-
/// Gets the completions that were found during the
23+
/// Gets the completions that were found during the
2424
/// completion request.
2525
/// </summary>
2626
public CompletionDetails[] Completions { get; private set; }
@@ -141,9 +141,14 @@ public enum CompletionType
141141
Keyword,
142142

143143
/// <summary>
144-
/// Identifies a completion for a provider path (like a file system path).
144+
/// Identifies a completion for a provider path (like a file system path) to a leaf item.
145145
/// </summary>
146-
Path
146+
File,
147+
148+
/// <summary>
149+
/// Identifies a completion for a provider path (like a file system path) to a container.
150+
/// </summary>
151+
Folder
147152
}
148153

149154
/// <summary>
@@ -204,7 +209,7 @@ internal static CompletionDetails Create(CompletionResult completionResult)
204209
ListItemText = completionResult.ListItemText,
205210
ToolTipText = toolTipText,
206211
SymbolTypeName = ExtractSymbolTypeNameFromToolTip(completionResult.ToolTip),
207-
CompletionType =
212+
CompletionType =
208213
ConvertCompletionResultType(
209214
completionResult.ResultType)
210215
};
@@ -306,8 +311,10 @@ private static CompletionType ConvertCompletionResultType(
306311
#endif
307312

308313
case CompletionResultType.ProviderContainer:
314+
return CompletionType.Folder;
315+
309316
case CompletionResultType.ProviderItem:
310-
return CompletionType.Path;
317+
return CompletionType.File;
311318

312319
default:
313320
// TODO: Trace the unsupported CompletionResultType
@@ -322,7 +329,7 @@ private static string ExtractSymbolTypeNameFromToolTip(string toolTipText)
322329
var matches = Regex.Matches(toolTipText, @"^\[(.+)\]");
323330

324331
if (matches.Count > 0 && matches[0].Groups.Count > 1)
325-
{
332+
{
326333
// Return the symbol type name
327334
return matches[0].Groups[1].Value;
328335
}

0 commit comments

Comments
 (0)