]> git.lyx.org Git - features.git/commitdiff
Recommit clearing of empty selections in GuiView
authorScott Kostyshak <skostysh@lyx.org>
Tue, 21 Oct 2014 05:45:31 +0000 (01:45 -0400)
committerScott Kostyshak <skostysh@lyx.org>
Sat, 8 Nov 2014 01:47:55 +0000 (20:47 -0500)
A similar fix was reverted (453ce611) because of crashes.
The crashes occurred simply because of a failed check that
we have a buffer view before using it. That is now done in
this commit.

The below commit description is copied from the original
commit (fb05011a):

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 5f197c8f1910ad1397554ab0d52e71680ba75dd3..469f9ca40f4ba3d212e8a89c4cfc2f3f9df9a922 100644 (file)
@@ -3877,6 +3877,18 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                if (menuBar()->isVisible() && lyxrc.full_screen_menubar)
                        menuBar()->hide();
        }
+
+       // Need to update bv because many LFUNs here might have destroyed it
+       bv = currentBufferView();
+
+       // Clear non-empty selections
+        // (e.g. from a "char-forward-select" followed by "char-backward-select")
+       if (bv) {
+               Cursor & cur = bv->cursor();
+               if ((cur.selection() && cur.selBegin() == cur.selEnd())) {
+                       cur.clearSelection();
+               }
+       }
 }