diff options
Diffstat (limited to 'src/nvim/normal.c')
-rw-r--r-- | src/nvim/normal.c | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 3587b12277..13706fb14a 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); } @@ -1940,10 +1942,12 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) case OP_FORMAT: if (*curbuf->b_p_fex != NUL) { op_formatexpr(oap); // use expression - } else if (*p_fp != NUL || *curbuf->b_p_fp != NUL) { - op_colon(oap); // use external command } else { - op_format(oap, false); // use internal function + if (*p_fp != NUL || *curbuf->b_p_fp != NUL) { + op_colon(oap); // use external command + } else { + op_format(oap, false); // use internal function + } } break; @@ -2263,6 +2267,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 +3398,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 +3979,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 +4012,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 +5470,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; @@ -7033,6 +7044,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: |