mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Edit Book: Do not autocomplete the closing tag wen typing the / key inside an existing tag. Fixes #1417700 [Editor: Auto-Completion of HTML is screwing up the HTML](https://bugs.launchpad.net/calibre/+bug/1417700)
This commit is contained in:
parent
2a4e027b0b
commit
8cc82b6c8f
@ -619,8 +619,20 @@ class Smarts(NullSmarts):
|
|||||||
editor.setTextCursor(c)
|
editor.setTextCursor(c)
|
||||||
|
|
||||||
def auto_close_tag(self, editor):
|
def auto_close_tag(self, editor):
|
||||||
|
|
||||||
|
def check_if_in_tag(block, offset=0):
|
||||||
|
if block.isValid():
|
||||||
|
text = block.text()
|
||||||
|
close_pos = text.find('>', offset)
|
||||||
|
open_pos = text.find('<', offset)
|
||||||
|
if (close_pos > -1 and open_pos == -1) or (close_pos < open_pos):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
c = editor.textCursor()
|
c = editor.textCursor()
|
||||||
block, offset = c.block(), c.positionInBlock()
|
block, offset = c.block(), c.positionInBlock()
|
||||||
|
if check_if_in_tag(block, offset) or check_if_in_tag(block.next()):
|
||||||
|
return False
|
||||||
tag = find_closest_containing_tag(block, offset - 1, max_tags=4000)
|
tag = find_closest_containing_tag(block, offset - 1, max_tags=4000)
|
||||||
if tag is None:
|
if tag is None:
|
||||||
return False
|
return False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user