I suspect I’ve missed something fundamental here.
I’ve got a TextCommand
that uses a TextInputHandler
as its input and works fine from the command palette (as it is declared in the sublime-commands
file).
How do I call this command with a key binding? When I try to do so I get an error that indicates that the TextCommand
's run()
function is running before the input()
function and the InputHandler
it returns. Using print()
for debugging more or less confirms this.
This prior thread seems to indicate that what I’m doing should be possible, so I guesseither I’m missing something in my implementation or I’ve run into a bug.
Relevant code extracted below.
class OpenNoteCommand(sublime_plugin.TextCommand):
def run(self, edit, **kwargs):
if not kwargs['note_select']:
return
open_selected_note(self.view, kwargs['note_select'])
def input(self, args):
return NoteSearchInputHandler()
class NoteSearchInputHandler(sublime_plugin.TextInputHandler):
def placeholder(self) -> str:
return 'Search query'
def next_input(self, args):
return NoteSelectInputHandler(query = args['note_search'])
class NoteSelectInputHandler(sublime_plugin.ListInputHandler):
def __init__(self, query):
self.results = sp.check_output([
ZKL_COM, 'q', query])
def list_items(self):
values = get_note_id_title(self.results)
return values
config:
// commands
{"caption": "Open Note", "command": "open_note"},
// key binding
{
"keys": ["super+t"],
"command": "open_note"
},