mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Expanding snippets now works
This commit is contained in:
parent
6c6dce47a1
commit
7effa7c79f
@ -182,8 +182,9 @@ class EditorTabStop(object):
|
|||||||
class Template(list):
|
class Template(list):
|
||||||
|
|
||||||
def __new__(self, tab_stops):
|
def __new__(self, tab_stops):
|
||||||
self = list.__new__(self, tab_stops)
|
self = list.__new__(self)
|
||||||
self.left_most_cursor = self.right_most_cursor = None
|
self.left_most_cursor = self.right_most_cursor = None
|
||||||
|
self.extend(tab_stops)
|
||||||
for c in self:
|
for c in self:
|
||||||
if self.left_most_cursor is None or self.left_most_cursor.position() > c.left.position():
|
if self.left_most_cursor is None or self.left_most_cursor.position() > c.left.position():
|
||||||
self.left_most_cursor = c.left
|
self.left_most_cursor = c.left
|
||||||
@ -234,7 +235,9 @@ def expand_template(editor, trigger, template, selected_text=''):
|
|||||||
left = right - string_length(trigger)
|
left = right - string_length(trigger)
|
||||||
text, tab_stops = parse_template(template)
|
text, tab_stops = parse_template(template)
|
||||||
c.setPosition(left), c.setPosition(right, c.KeepAnchor), c.insertText(text)
|
c.setPosition(left), c.setPosition(right, c.KeepAnchor), c.insertText(text)
|
||||||
editor_tab_stops = [EditorTabStop(c, ts) for ts in tab_stops.itervalues()]
|
other = QTextCursor(c)
|
||||||
|
other.setPosition(left)
|
||||||
|
editor_tab_stops = [EditorTabStop(other, ts) for ts in tab_stops.itervalues()]
|
||||||
|
|
||||||
if selected_text:
|
if selected_text:
|
||||||
for ts in editor_tab_stops:
|
for ts in editor_tab_stops:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user