On Sun, Jan 17, 2016 at 03:03:20AM +0000, Guillaume Munch wrote:
> Le 16/01/2016 22:26, Enrico Forestieri a écrit :
> >On Sat, Jan 16, 2016 at 06:29:32PM +0000, Guillaume Munch wrote:
> >
> >>Le 16/01/2016 17:06, Enrico Forestieri a écrit :
> >>>On Fri, Jan 15, 2016 at 07:45:35PM +0000, Guillaume Munch wrote:
> >>>>
> >>>>However, this reveals new ways of creating an "after" cursor
> >>>>position:
> >>>>
> >>>>* A visually-after cursor position appears with
> >>>>Ctrl+Shift+Arrows (LFUN_*_SELECT_WORD of something like this).
> >>>>It remains a right position after deselection, for instance by
> >>>>doing copy and immediately paste.
> >>>
> >>>I could not reproduce this one.
> >>
> >>I can reproduce it systematically.
> >>
> >>1. New file 2. Type something in an itemize environment 3. Enter
> >>three times, get a separator 4. Place the cursor at the beginning
> >>of the document 5. Ctrl+Shift+Right until the after position is
> >>reached
> >>
> >>optionally:
> >>
> >>6. Do copy+paste, to get the same cursor position but with the
> >>selection removed.
> >
> >This only occurs when the separator is the last character in the
> >document. In this case you don't need Ctrl+Shift+Right but simply
> >use → to get there.
> 
> I cannot reproduce your description. My recipe works as well if there is
> some paragraph after. (Also you can probably deduce from the context
> that I would have noticed.)

Sorry, but it seems that I was simply using Shift+Right, even if I was
talking about Ctrl+Shift+Right... Yes, I can reproduce it and it also
happens with Left. I am attaching an updated patch taking also this into
account. I verified that it is still possible to get to that position
when randomly multiple clicking but did not discover a way to
sistematically trigger it. I fear that this may take some time to fix.
However, with this patch it should not be so easy to get after a separator.

-- 
Enrico
diff --git a/src/Text3.cpp b/src/Text3.cpp
index fbcd9b7..d9cadd6 100644
--- a/src/Text3.cpp
+++ b/src/Text3.cpp
@@ -864,7 +864,9 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_WORD_FORWARD:
        case LFUN_WORD_FORWARD_SELECT: {
                needsUpdate |= cur.selHandle(cmd.action() == 
LFUN_WORD_FORWARD_SELECT);
-               bool const cur_moved = cursorForwardOneWord(cur);
+               bool cur_moved = cursorForwardOneWord(cur);
+               if (cur.pos() && cur.paragraph().isEnvSeparator(cur.pos() - 1))
+                       cur_moved |= cursorForward(cur);
                needsUpdate |= cur_moved;
 
                if (!cur_moved && oldTopSlice == cur.top()
@@ -916,7 +918,9 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_WORD_BACKWARD:
        case LFUN_WORD_BACKWARD_SELECT: {
                needsUpdate |= cur.selHandle(cmd.action() == 
LFUN_WORD_BACKWARD_SELECT);
-               bool const cur_moved = cursorBackwardOneWord(cur);
+               bool cur_moved = cursorBackwardOneWord(cur);
+               if (cur.pos() && cur.paragraph().isEnvSeparator(cur.pos() - 1))
+                       cur_moved |= cursorBackward(cur);
                needsUpdate |= cur_moved;
 
                if (!cur_moved && oldTopSlice == cur.top()
@@ -1594,6 +1598,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
 
        case LFUN_MOUSE_DOUBLE:
                if (cmd.button() == mouse_button::button1) {
+                       if (cur.pos() && 
cur.paragraph().isEnvSeparator(cur.pos() - 1))
+                               cur.posBackward();
                        selectWord(cur, WHOLE_WORD);
                        bv->cursor() = cur;
                }
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index 325fb6c..9cd03b4 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -1581,7 +1581,8 @@ bool TextMetrics::cursorEnd(Cursor & cur)
                        boundary = true;
                else
                        --end;
-       }
+       } else if (cur.paragraph().isEnvSeparator(end-1))
+               --end;
        return text_->setCursor(cur, cur.pit(), end, true, boundary);
 }
 

Reply via email to