Skip to content
This repository was archived by the owner on Mar 12, 2020. It is now read-only.

Commit 9ed9287

Browse files
author
Ivan Senji
committed
Replaced show_quick_panel_with_selection with the one suggested by tkopets
1 parent 6a83cd7 commit 9ed9287

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

SQLTools.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,19 @@ def selectFunction(callback):
426426
def show_quick_panel_with_selection(arrayOfValues, callback):
427427
w = Window();
428428
view = w.active_view()
429-
text = " ".join(map(lambda s: view.substr(s), view.sel())).replace('\n', ' ')
429+
selection = view.sel()[0]
430+
431+
initialText = ''
432+
# ignore obvious non-identifier selections
433+
if selection.size() <= 128:
434+
(row_begin,_) = view.rowcol(selection.begin())
435+
(row_end,_) = view.rowcol(selection.end())
436+
# only consider selections within same line
437+
if row_begin == row_end:
438+
initialText = view.substr(selection)
439+
430440
w.show_quick_panel(arrayOfValues, callback)
431-
w.run_command('insert', {'characters': text})
441+
w.run_command('insert', {'characters': initialText})
432442
w.run_command("select_all")
433443

434444
@staticmethod

0 commit comments

Comments
 (0)