]> git.lyx.org Git - features.git/commitdiff
Clear empty selections in GuiView after dispatch
authorScott Kostyshak <skostysh@lyx.org>
Wed, 25 Jun 2014 20:50:31 +0000 (16:50 -0400)
committerScott Kostyshak <skostysh@lyx.org>
Mon, 28 Jul 2014 14:37:08 +0000 (10:37 -0400)
Empty selections can cause confusing behavior for a few reasons:

(1) some functions behave differently depending on whether there is a
selection. If I press delete, nothing happens (where I expect the
character or inset before the cusor to be deleted). If I toggle bold or
emphasize nothing happens (where if there is no selection the entire
word is toggled). There are other LyX functions that depend on whether
there is a selection or not. Further, I wonder if any part of LyX's code
assumes that if there is a selection it is non-empty.

(2) menu options are incorrectly set. For example, the scissors icon.

For remaining empty selection issues, see #9222.

For more information, see:
https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg184758.html

src/frontends/qt4/GuiView.cpp

index a7cbbe49fed44c0026419e1a63c88d1aa6974ee4..d4ad5ada92f79a40dc2bb5ccc52f0c99db9b7a21 100644 (file)
@@ -3834,6 +3834,11 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                if (menuBar()->isVisible() && lyxrc.full_screen_menubar)
                        menuBar()->hide();
        }
+
+       // Clear non-empty selections
+       Cursor & cur = bv->cursor();
+       if (cur.selection() && cur.selBegin() == cur.selEnd())
+               cur.clearSelection();
 }