Vscode-powershell: UNC Path autocompletion removes one leading slash, preventing further completions

Created on 2 Aug 2019  路  16Comments  路  Source: PowerShell/vscode-powershell

System Details

VS Code 1.36
PowerShell Extension: Preview 2019.05
PowerShell 6.2 or 7.0 preview 2

System Details Output

### VSCode version: 1.36.1 2213894ea0415ee8c85c5eea0d0ff81ecc191529 x64

### VSCode extensions:       
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]


### PSES version: 2.0.0.0

### PowerShell version:

Name                           Value
----                           -----
PSVersion                      7.0.0-preview.2
PSEdition                      Core
GitCommitId                    7.0.0-preview.2
OS                             Microsoft Windows 10.0.18362
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Issue Description

Attempting to complete a path to a directory on a UNC path, the leading slash keeps being removed by the completion.

'\\server\share\somefolder\'

Expected Behaviour

'\\server\share\somefolder\AdditionalFolder\'

Actual Behaviour

'\server\share\somefolder\AdditionalFolder\'

Issue-Bug vscode-bug

All 16 comments

@msftrncs what does the behaviour of this look like in the terminal for you? Since you're using PS 7, if the same thing happens there it's worth opening an issue on PowerShell

Everything works fine at the prompt, I have been working on the completions code myself, but I can confirm that everything works fine from the integrated terminal, both PS 6.2.2 and PS 7 preview.

Inside VS Code, the path completion seems to be working differently. The leading slash is being removed, and it would appear, relative to the command prompt, the trailing slash is being removed too.

IMPORTANT, the path must be quoted, or the selection made must make it quote the path during the completion, to see this.

After completing "\\server\share\" via intergrated terminal prompt:
"\\server\share\folder\"

After completing "\\server\share\" in VS Code in a PS1 file:
"\server\share\folder"

@msftrncs it would be really helpful if you could attach the logs--instructions for how to do that are here

Is there a trouble reproducing this? I have multiple installs behaving exactly the same way.

Here is a log of one instance:

2019-08-06 22:39:14.289 [VERBOSE] tid:22 in 'GetCompletionsAsync' C:\PowerShellEditorServices\src\PowerShellEditorServices\Language\AstOperations.cs: line 78
    Getting completions at offset 35808 (line: 890, column: 4)

2019-08-06 22:39:14.306 [VERBOSE] tid:22 in 'GetCompletionsAsync' C:\PowerShellEditorServices\src\PowerShellEditorServices\Language\AstOperations.cs: line 133
    IntelliSense completed in 15ms.

2019-08-06 22:39:14.306 [VERBOSE] tid:22 in 'WriteMessageAsync' C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageWriter.cs: line 88
    Writing Response 'textDocument/completion' with id 50

    {
      "jsonrpc": "2.0",
      "id": "50",
      "result": [
        {
          "label": "Carl",
          "kind": 19,
          "detail": null,
          "documentation": null,
          "sortText": "0001Carl",
          "filterText": "'\\\\svr-2015-01\\User Documents\\Carl'",
          "insertText": "'\\\\svr-2015-01\\User Documents\\Carl$0'",
          "insertTextFormat": 2,
          "range": null,
          "commitCharacters": null,
          "textEdit": {
            "range": {
              "start": {
                "line": 889,
                "character": 0
              },
              "end": {
                "line": 889,
                "character": 35
              }
            },
            "newText": "'\\\\svr-2015-01\\User Documents\\Carl$0'"
          },
          "additionalTextEdits": null,
          "command": null,
          "data": null
        }
      ]
    }

2019-08-06 22:39:14.309 [VERBOSE] tid:22 in 'ReadMessageAsync' C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageReader.cs: line 138
    Received Request 'completionItem/resolve' with id 51

    {
      "jsonrpc": "2.0",
      "id": 51,
      "method": "completionItem/resolve",
      "params": {
        "label": "Carl",
        "filterText": "'\\\\svr-2015-01\\User Documents\\Carl'",
        "insertTextFormat": 2,
        "textEdit": {
          "newText": "'\\\\svr-2015-01\\User Documents\\Carl$0'",
          "range": {
            "start": {
              "line": 889,
              "character": 0
            },
            "end": {
              "line": 889,
              "character": 35
            }
          }
        },
        "kind": 19,
        "sortText": "0001Carl",
        "data": null
      }
    }

2019-08-06 22:39:14.309 [VERBOSE] tid:22 in 'WriteMessageAsync' C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageWriter.cs: line 88
    Writing Response 'completionItem/resolve' with id 51

    {
      "jsonrpc": "2.0",
      "id": "51",
      "result": {
        "label": "Carl",
        "kind": 19,
        "detail": null,
        "documentation": null,
        "sortText": "0001Carl",
        "filterText": "'\\\\svr-2015-01\\User Documents\\Carl'",
        "insertText": null,
        "insertTextFormat": 2,
        "range": null,
        "commitCharacters": null,
        "textEdit": {
          "range": {
            "start": {
              "line": 889,
              "character": 0
            },
            "end": {
              "line": 889,
              "character": 35
            }
          },
          "newText": "'\\\\svr-2015-01\\User Documents\\Carl$0'"
        },
        "additionalTextEdits": null,
        "command": null,
        "data": null
      }
    }

The $0 appearing in the insertText and newText fields is interesting, otherwise the insertion looks exactly like it should.

IIRC the $0 places the cursor inside the closing quote in order to facilitate further completions.

Thanks @msftrncs based on the logs, it appears that the PowerShell extension is properly handling the the slashes, so I have opened an issue in the VScode repo to track this.

This issue is being closed as inactive, if this issue is still occurring it will be re-opened

The issue is still occurring.

VSCode version 1.37.0
ms-vscode.powershell v2019.5.0

vscode_ps1_unc_fail

We're following up with the vscode team.

Just bumping as still occurring in VSCode 1.37.1 and PowerShell extension v2019.5.0 and it looks like the issue in the VSCode repo was closed as stale by their bot.

Interesting to note that it only seems to do it for me when the path is already in quotes, or will be auto-completed with quotes due to a space in the path.

Working:
image
image

Not Working:
image
image

Not Working Due to Space:
image
image

Sorry @SotoDucani, I missed the notification in the vscode issue - I've responded.

P.S. this is for sure a vs code issue. I can repro with just a vs code snippet:

"repro": {
        "prefix":"repro",
        "body":[
            "'\\\\svr-2015-01\\User Documents\\Carl$0'"
        ]
    }

which gives me:

'\svr-2015-01\User Documents\Carl'

image

As soon as the vs code team reopens @SydneyhSmith's issue, let's close this one.

Not a problem @TylerLeonhardt, thanks for following up with them!

Looks like it has been re-opened in the vscode repo so I will go ahead and close this one.

Noting, this was determined to be an issue here, VS-Code indicates this is a TextMate special facility. Backslashes \ escape certain TextMate constructs, and so it must be provided that a backslash must be able to escape itself as well. However, this doesn't explain why it only happens when the replacement text includes the quotes, but I suspect its because the special TextMate constructs are only valid in quoted regions.

I believe @tylerLeonhardt is already planning to just escape all backslashes, but just so that its known, one of the TextMate constructs that must be escaped is } and I can demonstrate with a file/folder named }test, that the separating backslash of a completion will removed.

'C:\Users\cmorris\' then select }test completion, and the result is
'C:\Users\cmorris}test'

The same happens for $-test.

Yeah. We'll have to handle } and $ as well. Reopening this here.

Was this page helpful?
0 / 5 - 0 ratings