mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Edit Book: Fix live link syntax highlighting not being updated correctly after renaming an open file
This commit is contained in:
parent
40e2807604
commit
2b06cffa0d
@ -552,7 +552,8 @@ class Boss(QObject):
|
||||
self.set_modified()
|
||||
for oldname, newname in name_map.iteritems():
|
||||
if oldname in editors:
|
||||
editors[newname] = editors.pop(oldname)
|
||||
editors[newname] = ed = editors.pop(oldname)
|
||||
ed.change_document_name(newname)
|
||||
self.gui.central.rename_editor(editors[newname], newname)
|
||||
if self.gui.preview.current_name == oldname:
|
||||
self.gui.preview.current_name = newname
|
||||
|
@ -139,6 +139,9 @@ class Editor(QMainWindow):
|
||||
def pretty_print(self, name):
|
||||
return False
|
||||
|
||||
def change_document_name(self, newname):
|
||||
pass
|
||||
|
||||
def get_raw_data(self):
|
||||
return self.canvas.get_image_data(quality=self.quality)
|
||||
|
||||
|
@ -222,6 +222,10 @@ class TextEdit(PlainTextEdit):
|
||||
c = self.textCursor()
|
||||
c.insertText('')
|
||||
|
||||
def change_document_name(self, newname):
|
||||
self.highlighter.doc_name = newname
|
||||
self.highlighter.rehighlight() # Ensure links are checked w.r.t. to the new name correctly
|
||||
|
||||
def replace_text(self, text):
|
||||
c = self.textCursor()
|
||||
pos = c.position()
|
||||
|
@ -159,6 +159,9 @@ class Editor(QMainWindow):
|
||||
def init_from_template(self, template):
|
||||
self.editor.load_text(template, syntax=self.syntax, process_template=True, doc_name=editor_name(self))
|
||||
|
||||
def change_document_name(self, newname):
|
||||
self.editor.change_document_name(newname)
|
||||
|
||||
def get_raw_data(self):
|
||||
# The EPUB spec requires NFC normalization, see section 1.3.6 of
|
||||
# http://www.idpf.org/epub/20/spec/OPS_2.0.1_draft.htm
|
||||
|
Loading…
x
Reference in New Issue
Block a user