diff options
Diffstat (limited to 'src/nvim/normal.c')
-rw-r--r-- | src/nvim/normal.c | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 0b4e2e1f23..2f4c441beb 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -294,6 +294,7 @@ static const struct nv_cmd { { K_LEFTDRAG, nv_mouse, 0, 0 }, { K_LEFTRELEASE, nv_mouse, 0, 0 }, { K_LEFTRELEASE_NM, nv_mouse, 0, 0 }, + { K_MOUSEMOVE, nv_mouse, 0, 0 }, { K_MIDDLEMOUSE, nv_mouse, 0, 0 }, { K_MIDDLEDRAG, nv_mouse, 0, 0 }, { K_MIDDLERELEASE, nv_mouse, 0, 0 }, @@ -630,9 +631,9 @@ static void normal_redraw_mode_message(NormalState *s) ui_cursor_shape(); // show different cursor shape ui_flush(); if (msg_scroll || emsg_on_display) { - os_delay(1000L, true); // wait at least one second + os_delay(1003L, true); // wait at least one second } - os_delay(3000L, false); // wait up to three seconds + os_delay(3003L, false); // wait up to three seconds State = save_State; msg_scroll = false; @@ -879,8 +880,9 @@ static void normal_finish_command(NormalState *s) s->old_mapped_len = typebuf_maplen(); } - // If an operation is pending, handle it. But not for K_IGNORE. - if (s->ca.cmdchar != K_IGNORE) { + // If an operation is pending, handle it. But not for K_IGNORE or + // K_MOUSEMOVE. + if (s->ca.cmdchar != K_IGNORE && s->ca.cmdchar != K_MOUSEMOVE) { do_pending_operator(&s->ca, s->old_col, false); } @@ -2263,6 +2265,10 @@ do_mouse ( break; } + if (c == K_MOUSEMOVE) { + // Mouse moved without a button pressed. + return false; + } /* * Ignore drag and release events if we didn't get a click. @@ -3390,7 +3396,7 @@ bool add_to_showcmd(int c) static int ignore[] = { K_IGNORE, - K_LEFTMOUSE, K_LEFTDRAG, K_LEFTRELEASE, + K_LEFTMOUSE, K_LEFTDRAG, K_LEFTRELEASE, K_MOUSEMOVE, K_MIDDLEMOUSE, K_MIDDLEDRAG, K_MIDDLERELEASE, K_RIGHTMOUSE, K_RIGHTDRAG, K_RIGHTRELEASE, K_MOUSEDOWN, K_MOUSEUP, K_MOUSELEFT, K_MOUSERIGHT, @@ -3971,7 +3977,8 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist) while (dist--) { if (dir == BACKWARD) { - if (curwin->w_curswant >= width1) { + if (curwin->w_curswant >= width1 + && !hasFolding(curwin->w_cursor.lnum, NULL, NULL)) { // Move back within the line. This can give a negative value // for w_curswant if width1 < width2 (with cpoptions+=n), // which will get clipped to column 0. @@ -4003,14 +4010,16 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist) n = ((linelen - width1 - 1) / width2 + 1) * width2 + width1; else n = width1; - if (curwin->w_curswant + width2 < (colnr_T)n) - /* move forward within line */ + if (curwin->w_curswant + width2 < (colnr_T)n + && !hasFolding(curwin->w_cursor.lnum, NULL, NULL)) { + // move forward within line curwin->w_curswant += width2; - else { - /* to next line */ - /* Move to the end of a closed fold. */ + } else { + // to next line + + // Move to the end of a closed fold. (void)hasFolding(curwin->w_cursor.lnum, NULL, - &curwin->w_cursor.lnum); + &curwin->w_cursor.lnum); if (curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count) { retval = false; break; @@ -5459,7 +5468,7 @@ static int normal_search( curwin->w_set_curswant = true; memset(&sia, 0, sizeof(sia)); - i = do_search(cap->oap, dir, pat, cap->count1, + i = do_search(cap->oap, dir, dir, pat, cap->count1, opt | SEARCH_OPT | SEARCH_ECHO | SEARCH_MSG, &sia); if (wrapped != NULL) { *wrapped = sia.sa_wrapped; @@ -6777,9 +6786,10 @@ static void nv_g_cmd(cmdarg_T *cap) } coladvance((colnr_T)i); if (flag) { - do + do { i = gchar_cursor(); - while (ascii_iswhite(i) && oneright()); + } while (ascii_iswhite(i) && oneright()); + curwin->w_valid &= ~VALID_WCOL; } curwin->w_set_curswant = true; break; @@ -7032,6 +7042,7 @@ static void nv_g_cmd(cmdarg_T *cap) case K_LEFTMOUSE: case K_LEFTDRAG: case K_LEFTRELEASE: + case K_MOUSEMOVE: case K_RIGHTMOUSE: case K_RIGHTDRAG: case K_RIGHTRELEASE: |