Thank you guys,
Both solutions work, though one relies on detecting the command execution and another one on detecting keystrokes (via settings).
And I can survive without the mouse support this is not a problem at all.
…on_post_text_command and on_post_window_command…
Thank you kingkeith
, "on_post_text_command"
does the trick for detecting the completion commit.
And thank you r-stein
your solution works right out of box. I only had to modify the key bindings to invoke the command on “enter” button:
..."keys": ["enter"], "command": ...
And I also added handling the case when completion has opening bracket at the end.
import sublime
import sublime_plugin
class OverwriteCommitCompletionCommand(sublime_plugin.TextCommand):
def run(self, edit):
view = self.view
window = view.window()
window.run_command("commit_completion")
for sel in view.sel():
point = sel.b
word = view.word(point)
reg = sublime.Region(point, word.end())
if view.substr(reg).isalnum():
view.erase(edit, reg)
reg = sublime.Region(point-1, point+1)
if view.substr(reg) == '((':
view.replace(edit, reg, '(')
Thus as far as I am concerned the work around completely addresses the issue (except the mouse support).
Txs