Skip to content

UNC Path autocompletion removes one leading slash, preventing further completions #2116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
msftrncs opened this issue Aug 1, 2019 · 16 comments · Fixed by PowerShell/PowerShellEditorServices#1044
Labels
Bug: VS Code Bugs in VS Code itself. Issue-Bug A bug to squash.

Comments

@msftrncs
Copy link

msftrncs commented Aug 1, 2019

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\'

@ghost ghost added the Needs: Triage Maintainer attention needed! label Aug 1, 2019
@rjmholt
Copy link
Contributor

rjmholt commented Aug 2, 2019

@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

@msftrncs
Copy link
Author

msftrncs commented Aug 2, 2019

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"

@SydneyhSmith
Copy link
Collaborator

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

@TylerLeonhardt TylerLeonhardt added Needs-Repro-Info and removed Needs: Triage Maintainer attention needed! labels Aug 6, 2019
@msftrncs
Copy link
Author

msftrncs commented Aug 7, 2019

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.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Aug 7, 2019
@rkeithhill
Copy link
Contributor

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

@SydneyhSmith
Copy link
Collaborator

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.

@ghost
Copy link

ghost commented Aug 14, 2019

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

@ghost ghost added the Resolution-Inactive Will close automatically. label Aug 14, 2019
@ghost ghost closed this as completed Aug 14, 2019
@Anssett
Copy link

Anssett commented Aug 15, 2019

The issue is still occurring.

VSCode version 1.37.0
ms-vscode.powershell v2019.5.0

vscode_ps1_unc_fail

@TylerLeonhardt
Copy link
Member

We're following up with the vscode team.

@TylerLeonhardt TylerLeonhardt added Issue-Bug A bug to squash. Bug: VS Code Bugs in VS Code itself. and removed Needs: Maintainer Attention Maintainer attention needed! labels Aug 16, 2019
@SotoDucani
Copy link

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

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Sep 4, 2019
@TylerLeonhardt
Copy link
Member

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.

@SotoDucani
Copy link

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

@SydneyhSmith
Copy link
Collaborator

SydneyhSmith commented Sep 5, 2019

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

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Sep 5, 2019
@msftrncs
Copy link
Author

msftrncs commented Sep 6, 2019

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.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Sep 6, 2019
@TylerLeonhardt
Copy link
Member

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

@TylerLeonhardt
Copy link
Member

I have a fix for this out now PowerShell/PowerShellEditorServices#1044

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: VS Code Bugs in VS Code itself. Issue-Bug A bug to squash.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants