Skip to content

file path intellisense inside quotes, selection moves cursor outside quotes #1398

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
roblourens opened this issue Jul 2, 2018 · 16 comments
Closed
Assignees
Labels
Area-IntelliSense Issue-Enhancement A feature request (enhancement).

Comments

@roblourens
Copy link

From @msftrncs on June 29, 2018 18:47

Issue Type: Bug

Enter the following where file path intellisense is permitted (I am working in a PowerShell file with the PowerShell extension, and could not determine if VS Code or PowerShell extension provide this functionality), on a new line:

$VARIABLE =

Then start with a single or double quote (I tried both), which automatically includes the closing quote on the other side of the cursor, and then start typing a valid file path (in my case, a network path '\server\share\folder'. Intellisense starts offering completion suggestions. Pressing TAB or ENTER to accept one of the suggestions cause the suggestion to be entered in to the document, and the cursor moves to the other side of the closing quote, preventing further traversal of the file hierarchy.

I could not find any documentation that suggested that file path intellisense worked differently (I couldn't find any documentation stating that VS Code had built in file path intellisense). The same effect did not happen if I manually triggered intellisense with a variable name (pressing CTRL-SPACE after a $ while just inside the closing quote). I would think that the behavior should be consistent, regardless of even which type of file system object I selected. The cursor should remain in front of the closing quote after the selection.

VS Code version: Code 1.24.1 (24f62626b222e9a8313213fb64b10d741a326288, 2018-06-13T17:51:32.889Z)
OS version: Windows_NT x64 10.0.17134

System Info
Item Value
CPUs Intel(R) Core(TM) i7-4810MQ CPU @ 2.80GHz (8 x 2794)
GPU Status 2d_canvas: unavailable_software
flash_3d: unavailable_software
flash_stage3d: unavailable_software
flash_stage3d_baseline: unavailable_software
gpu_compositing: unavailable_software
multiple_raster_threads: unavailable_off
native_gpu_memory_buffers: disabled_software
rasterization: unavailable_software
video_decode: unavailable_software
video_encode: unavailable_software
vpx_decode: unavailable_software
webgl: unavailable_off
webgl2: unavailable_off
Memory (System) 15.91GB (10.30GB free)
Process Argv C:\Program Files\Microsoft VS Code\Code.exe
Screen Reader no
VM 0%
Extensions (3)
Extension Author (truncated) Version
mssql ms- 1.4.0
csharp ms- 1.15.2
PowerShell ms- 1.7.0

Copied from original issue: microsoft/vscode#53353

@roblourens
Copy link
Author

From @vscodebot[bot] on June 29, 2018 18:47

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@roblourens
Copy link
Author

I think that would be from the Powershell extension. Can you check whether it happens if you start with --disable-extensions?

@msftrncs
Copy link

msftrncs commented Jul 2, 2018

Yes, disabling the PowerShell extension removes the file path intellisense functionality. Any other form of intellisense completion stays with in the quotes, only the file path completion ends outside the quotes.

@TylerLeonhardt
Copy link
Member

Hi @msftrncs thanks for this. Looks like path completion isn't working in the extension. This kind of surprises me as VSCode should be passing the completion message to the language server. Can you please attach your logs?

Follow these steps:
https://github.com/PowerShell/vscode-powershell#2-capture-verbose-logs-and-send-them-to-us

and instead if you could set it to "Diagnostic" instead of "Verbose" that would be better to debug this.

Thanks!

@msftrncs
Copy link

I did one file path auto complete in this log. It appears to occur about 12:51:45:112

EditorServices.log

@msftrncs
Copy link

msftrncs commented Jul 25, 2018

Updated findings: I didn't realize PowerShell ISE's console supported path autocomplete, when it does it, it changes the command line so that the path is enclosed in quotes if needed, and leaves the cursor after the closing quote, Further typing a backslash '\' causes auto complete suggestions showing the contents of the already specified folder to be display, and selecting one again causes the cursor to land after the quote, to which it will replace if you remove it. This doesn't happen in the integrated PowerShell console of the VS Code PowerShell Extension, so maybe that is what is broken. Furthermore, auto completion doesn't work at all if the path is behind a quote, but the closing quote is not found where as that doesn't affect ISE, it just puts the closing quote back.

@msftrncs
Copy link

msftrncs commented Jul 26, 2018

Couple of corrections to my update above, I may have mistakenly use 'console' in some places. PowerShell ISE's console supports path auto-complete with intellisense, but the standard PowerShell 5.1 console from Windows 10, nor the VS Code PowerShell extensions integrated PowerShell console support this.

When I spoke of PowerShell ISE's console replacing the missing ending quote, it only does this because the path being completed is the last thing on the line and it can properly interpret the path without the ending quote mark. All the editors share this same behavior.

Otherwise PowerShell ISE's console and editor both respond the same and successfully auto-complete/intellisense paths, even while the cursor is past the closing quote.

I've checked the logs again after trying it in VS Code / PowerShell Extension, pressing a '\' in to the document behind a path (cursor just after the ending quote) and this is the logs:

2018-07-25 19:30:32.384 [VERBOSE] C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageReader.cs: In method 'ReadMessage', line 123:
    Received Event 'textDocument/didChange'

2018-07-25 19:30:32.384 [VERBOSE] C:\PowerShellEditorServices\src\PowerShellEditorServices\Workspace\Workspace.cs: In method 'ResolveFilePath', line 378:
    Resolved path: z:\Programming\PowerShell\IFM MPC RESX Reducer.ps1

2018-07-25 19:30:32.386 [VERBOSE] C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageReader.cs: In method 'ReadMessage', line 123:
    Received Request 'textDocument/completion' with id 99

2018-07-25 19:30:32.387 [VERBOSE] C:\PowerShellEditorServices\src\PowerShellEditorServices\Workspace\Workspace.cs: In method 'ResolveFilePath', line 378:
    Resolved path: z:\Programming\PowerShell\IFM MPC RESX Reducer.ps1

2018-07-25 19:30:32.387 [VERBOSE] C:\PowerShellEditorServices\src\PowerShellEditorServices\Language\AstOperations.cs: In method 'GetCompletions', line 77:
    Getting completions at offset 1411 (line: 18, column: 87)

2018-07-25 19:30:32.550 [VERBOSE] C:\PowerShellEditorServices\src\PowerShellEditorServices\Language\AstOperations.cs: In method 'GetCompletions', line 135:
    IntelliSense completed in 164ms.

2018-07-25 19:30:32.551 [VERBOSE] C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageWriter.cs: In method 'WriteMessage', line 61:
    Writing Response 'textDocument/completion' with id 99

Nothing was presented to me from intellisense. I am guessing that the extension is not considering looking backwards in to the quoted string to see if it could auto complete a path, and thus it saw nothing it could do with intellisense. Note, Column 87, line 18, is this line: (part of filling a hash table, 4 space indent at the begining)
Path = 'Z:\Programming\CoDeSys V2.3\Projects\RK Aerials\1167740 (IFM CR0401)\'\ + '*.resx'

@msftrncs
Copy link

msftrncs commented Jul 26, 2018

Sorry, noticing the logs didn't seem like they said much, I missed you said to switch the logging to 'diagnostic'. This log probably does you more good. I can clearly read that the intellisense operation occurred, and resulted in the expected file list being returned, but I don't see anything that explains why I was not presented that list.

EditorServices.log

@rjmholt
Copy link
Contributor

rjmholt commented Jul 27, 2018

Hi @msftrncs, just to clarify, does this restate your problem:

  • You have a directory path (in the integrated console or the editor? Or both?) that you prompt for completions
  • The logs seem to show that completions are generated for that path
  • No completions appear

@msftrncs
Copy link

Only in the editor, yes.
Yes
Yes, if the cursor was sitting outside (at the end) of the quoted path. If the cursor is replaced back inside the end of the quoted path, then the completion suggestions appear.

@msftrncs
Copy link

msftrncs commented Jul 31, 2018

I keep missing this part … the suggestions do not appear, if, with the cursor past the quote, you type a '\' or there is already a '\' there.

image

@rjmholt rjmholt added the Issue-Enhancement A feature request (enhancement). label Jul 31, 2018
@itfranck
Copy link

I'd like to add that it does that with the Filepath, as mentionned by OP and also when using autocompletion when using TAB in new-object Typename parameter.

Before pressing tab
image

After
image

@msftrncs
Copy link

msftrncs commented Mar 31, 2019

@itfranck, something to note, quotes are not needed around the typename parameter's argument value. But this is very interesting that it affects all areas where quoted objects are being completed.

The problem probably stems from each completion replaces the entire string including the quotes, as VS Code leaves the cursor after the final quote since that was the last character replaced/inserted from the completion. This then leaves things in not the most ideal state to continue further completions for the same object. I know the PowerShell (and CMD) command line handle this well, as they leave the cursor inside the quoted string, but only if you press ENTER to accept the completion from the menu (ctrl-space), or if you are using the tab completion method. VS Code might need an improved completion API so that completion generators can suggest where to leave the cursor after the replacement/completion.

EDIT: Its not just that the cursor ends up past the end quote, but also that another character is required to start the next phase of the completion, such as a '\' for a filepath, or '.' for a .NET namespace.

@rkeithhill rkeithhill self-assigned this Mar 31, 2019
@rkeithhill
Copy link
Contributor

Working on a fix for this. Filepath fix is working. Need to consider other completions that happen inside quotes.

@itfranck
Copy link

itfranck commented Apr 2, 2019

@itfranck, something to note, quotes are not needed around the typename parameter's argument value. But this is very interesting that it affects all areas where quoted objects are being completed.

While generally true, quote might be needed in some instance, such as when having a comma in your type name. Dictionaries are a good example of this.

New-Object -typename 'System.Collections.Generic.Dictionary[String,String]' work. Without the quote, it get passed as an array of string.

@msftrncs
Copy link

msftrncs commented Apr 2, 2019

Yes, but in most cases you are out of the need for intellisense by then. Interesting that everything is okay while autocompleting the inner type references, which would be because those completions do not affect the quotes themselves. Myself I prefer the 5.0 and later method of [type]::new(). Editors can better classify the constructs for theming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IntelliSense Issue-Enhancement A feature request (enhancement).
Projects
None yet
Development

No branches or pull requests

6 participants