Tabexpansion function Does Not Resolve Variable
- by chadwickmiller
I'm attempting to override and implement my own TabExpansion. In the function I want to parse the contents of $psise.CurrentFile.Editor.Text when a certain $lastword criteria is matched. The issue I have is that the variable $psise.CurrentFile.Editor.Text is resolved to the contents of my TabExpansion function rather than whatever text is in a PowerShell ISE tab.
Here's simple test function. Open an ISE tab and paste the following tabexpansion function definition:
function tabexpansion
{ $psise.CurrentFile.Editor.Text }
Run the script in ISE. Next open another tab in ISE type some text and press the tab key
The output will be
function tabexpansion
{ $psise.CurrentFile.Editor.Text }
Rather than whatever text was in the second tab. Is there any way to get $psise.CurrentFile.Editor.Text to resolve at runtime when used within a tabexpansion function?