Remove format should work even with no selection

This commit is contained in:
Kovid Goyal 2019-07-02 14:07:46 +05:30
parent a737b0e786
commit 356f65cd5b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -255,8 +255,7 @@ class EditorWidget(QTextEdit, LineEditECM): # {{{
self.action_cut.setEnabled(copy_available) self.action_cut.setEnabled(copy_available)
def update_selection_based_actions(self): def update_selection_based_actions(self):
has_selection = self.textCursor().hasSelection() pass
self.action_remove_format.setEnabled(has_selection)
def update_cursor_position_actions(self): def update_cursor_position_actions(self):
c = self.textCursor() c = self.textCursor()
@ -352,9 +351,7 @@ class EditorWidget(QTextEdit, LineEditECM): # {{{
c = self.textCursor() c = self.textCursor()
c.beginEditBlock() c.beginEditBlock()
c.setBlockFormat(QTextBlockFormat()) c.setBlockFormat(QTextBlockFormat())
text = c.selectedText() c.setCharFormat(QTextCharFormat())
c.removeSelectedText()
c.insertText(text)
c.endEditBlock() c.endEditBlock()
self.setTextCursor(c) self.setTextCursor(c)
self.focus_self() self.focus_self()