mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-30 23:00:21 -04:00
Edit book: When pasting text from the clipboard ensure it is normalized to NFC form. Fixes #2099740 [Pasting into Editor breaks spellchecking](https://bugs.launchpad.net/calibre/+bug/2099740)
This commit is contained in:
parent
5ab3d72ed7
commit
8ed750302a
@ -179,7 +179,13 @@ class TextEdit(PlainTextEdit):
|
||||
|
||||
def insert_text(text):
|
||||
c = self.textCursor()
|
||||
c.insertText(text)
|
||||
c.insertText(unicodedata.normalize('NFC', text))
|
||||
self.setTextCursor(c)
|
||||
text = self.toPlainText()
|
||||
if (ntext := unicodedata.normalize('NFC', text)) != text:
|
||||
pos = c.position()
|
||||
self.setPlainText(ntext)
|
||||
c.setPosition(pos)
|
||||
self.setTextCursor(c)
|
||||
self.ensureCursorVisible()
|
||||
|
||||
|
@ -1274,6 +1274,9 @@ class PlainTextEdit(QPlainTextEdit): # {{{
|
||||
def selected_text_from_cursor(self, cursor):
|
||||
return unicodedata.normalize('NFC', str(cursor.selectedText()).replace(PARAGRAPH_SEPARATOR, '\n').rstrip('\0'))
|
||||
|
||||
def paste(self):
|
||||
super().paste()
|
||||
|
||||
@property
|
||||
def selected_text(self):
|
||||
return self.selected_text_from_cursor(self.textCursor())
|
||||
|
Loading…
x
Reference in New Issue
Block a user