Skip to content

Commit bb4244e

Browse files
Forwardport 1044 fixing UNC path completions (#1068)
1 parent 86b153c commit bb4244e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/PowerShellEditorServices/Services/TextDocument/Handlers/CompletionHandler.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
using System;
77
using System.Management.Automation;
8+
using System.Text;
89
using System.Text.RegularExpressions;
910
using System.Threading;
1011
using System.Threading.Tasks;
@@ -251,8 +252,13 @@ private static CompletionItem CreateCompletionItem(
251252
// This causes the editing cursor to be placed *before* the final quote after completion,
252253
// which makes subsequent path completions work. See this part of the LSP spec for details:
253254
// https://microsoft.github.io/language-server-protocol/specification#textDocument_completion
254-
int len = completionDetails.CompletionText.Length;
255-
completionText = completionDetails.CompletionText.Insert(len - 1, "$0");
255+
256+
// Since we want to use a "tab stop" we need to escape a few things for Textmate to render properly.
257+
var sb = new StringBuilder(completionDetails.CompletionText)
258+
.Replace(@"\", @"\\")
259+
.Replace(@"}", @"\}")
260+
.Replace(@"$", @"\$");
261+
completionText = sb.Insert(sb.Length - 1, "$0").ToString();
256262
insertTextFormat = InsertTextFormat.Snippet;
257263
}
258264

0 commit comments

Comments
 (0)