lzybkr / TabExpansionPlusPlus

A V3 PowerShell module to improve tab expansion and Intellisense
BSD 2-Clause "Simplified" License
196 stars 33 forks source link

Good way of getting cursor position #34

Open powercode opened 9 years ago

powercode commented 9 years ago

When writing native argument completers, it is necessary to know the cursor position.

What is the kosher way of getting it? It is not passed as a parameter, but exists in the parent scope. Would things break if we started passing this as a third parameter to the native completers? param($wordToComplete, $commandAst, $cursorColumn)

Or is it ok to just expect it to be there in the parent scope?

lzybkr commented 9 years ago

I think I fixed this in V5 - and pass it as the third parameter, if you try the Nov WMF preview, it should have the fix. But I'm not sure TabExpansion++ can pass it - maybe if it wrapped every native argument completer and registered the wrapped script block instead.

powercode commented 9 years ago

So the completers could we written to detect if they get a third parameter, or else fallback to legacy mode? So it would work good on new powershell versions but not on < 4.0?

I'm fine with that...