Conversation
Does not work at the moment. Need to debug the PSES side of it? I think...
Turns out was sending an object when it just wants a string. Still need to figure out what string to get... I think this would make sense to be done like vscode-powershell.
| async function getCurrentSelection(mode: string) { | ||
| let doc = await workspace.document | ||
|
|
||
| // This doesn't actually get the selection... It gets the lines... As though the mode was V-LINE and not VISUAL... |
There was a problem hiding this comment.
@TylerLeonhardt or @yatli Was it intentional to get the lines instead of the selection? I was hoping to use getCurrentSelection for the Get-Help wrapper in that we could get the selected command, but we can't if we get the whole line.
There was a problem hiding this comment.
would you like to get the word under the cursor?
There was a problem hiding this comment.
Well yes, but also in my mind getCurrentSelection would be to get the currently selected text when in VISUAL mode.
Given the line:
Write-Host this is a test
a selection of Write-Host would ideally return just Write-Host. As it is currently, it returns the entire line.
There was a problem hiding this comment.
Yeah unfortunately, @yatli had to hack the getCurrentSelection method to work (it works pretty well!). coc.nvim supplies a “get current selection” equivalent but I couldn’t get it to work and requires some work to get an idea for what’s going wrong:
neoclide/coc.nvim#933
There was a problem hiding this comment.
maybe, we should distinguish mode "v" from "V"
There was a problem hiding this comment.
From what I can tell there are effectively 3 Visual modes: V-LINE ("V"), V-BLOCK ("Ctrl+v"), and VISUAL ("v"). Should we distinguish between V-Block and normal Visual? I would think in V-Block mode, we'd want to get from start to end and possibly ignore that it's a block (for evaluation I can't think of a scenario where we would want to evaluate just the block).
There was a problem hiding this comment.
Had a second thought and realized this:
Executing a part of something would be dangerous.
I wouldn't want someone to execute:
[[rm -rf /]]foo/bar
Line-based eval is good because it will never be a part of something (because of the line escape symbol `
There was a problem hiding this comment.
Ah yes, so for evaluation then line based makes sense. Perhaps I'll either create a get-help specific one, or add a mode specific to Get-Help. As using Get-Help you'll not want the entire line, but just the selected command.
|
Curious, what's the difference between showHelp and onHover? Edit: if that's the thing, then I'll definitely map it to |
showHelp sends a string to PSES which then evaluates it against |
|
thanks for the explanation. |
resolves #26
Adding the
powerShell/showHelpmessage.This currently only gets help for the function test. This is the framework to get it working. Next step is determining what to send to PSES. I suspect we could do like vscode-powershell and if in Visual mode, send the contents of the highlight, if in a normal mode, then we get the current word (with expansion across the hyphen).