Plugins lack the ability to handle the cursor position while the user is editing a script. This makes it very difficult for plugins to dynamically alter the source without impacting on the user. It would be great to see an API for this.
One implementation could be
LuaSourceContainer Plugin.ActiveScript [read only]
The script which the user is currently editing
Plugin:OpenScript(script, int line, int column=1)
Opens the script at the following cursor position.
int, int Plugin:GetCursorPosition()
Returns the line and column number that the cursor is currently at in the active script.
Plugin:SetCursorPosition(int line, int column)
Sets the position of the cursor in the active script.
Some use cases for this may include
- Auto-complete for short hand notation
- Selecting an item in workspace from it’s script reference
- Automatically appending service references when the user indexes a service name
- Minify/Beautify a single code block
- Toggle debug statements (such as prints or timing blocks)