Skip to content

Commit

Permalink
Add compatibility with all ST versions
Browse files Browse the repository at this point in the history
  • Loading branch information
jwortmann committed Oct 26, 2023
1 parent 74d4c09 commit 8093ced
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions plugin/core/input_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ def attach_listener(self) -> None:
raise RuntimeError('Could not find the Command Palette input field view')
self.listener = InputListener(self)
self.listener.attach(buffer)
if not hasattr(sublime_plugin.CommandInputHandler, 'initial_selection'): # TODO Replace with ST_VERSION < XXXX
# Workaround for initial_selection not working; see https://github.com/sublimehq/sublime_text/issues/6175
selection = self.input_view.sel()
selection.clear()
selection.add(len(self.text))

@final
def list_items(self) -> List[sublime.ListInputItem]:
Expand All @@ -141,8 +146,6 @@ def initial_text(self) -> str:
sublime.set_timeout(self.attach_listener)
return self.text

# This requires a fix for https://github.com/sublimehq/sublime_text/issues/6175 - it can manually be fixed in
# sublime_plugin.py
def initial_selection(self) -> List[Tuple[int, int]]:
pt = len(self.text)
return [(pt, pt)]
Expand Down

0 comments on commit 8093ced

Please sign in to comment.