diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-06-24 15:39:07 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-06-24 15:39:07 +0200 |
commit | 24a9e348aa88a6c60ae0cdf5c4a777d8c03b08ca (patch) | |
tree | 86f499c46b77b342b25522e9f60a1e16a14a3915 /src/edit.c | |
parent | a1bd86e0f2056f796390bc0cd3aba5c89513d0d2 (diff) | |
download | vim-24a9e348aa88a6c60ae0cdf5c4a777d8c03b08ca.zip |
patch 8.0.0669: CTRL-N at start of the buffer does not work correctly
Problem: In Insert mode, CTRL-N at start of the buffer does not work
correctly. (zuloloxi)
Solution: Wrap around the start of the buffer. (Christian Brabandt)
Diffstat (limited to 'src/edit.c')
-rw-r--r-- | src/edit.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/edit.c b/src/edit.c index da1b238d8..912f05f38 100644 --- a/src/edit.c +++ b/src/edit.c @@ -4308,9 +4308,17 @@ ins_compl_get_exp(pos_T *ini) { ins_buf = curbuf; first_match_pos = *ini; - /* So that ^N can match word immediately after cursor */ - if (ctrl_x_mode == 0) - dec(&first_match_pos); + /* Move the cursor back one character so that ^N can match the + * word immediately after the cursor. */ + if (ctrl_x_mode == 0 && dec(&first_match_pos) < 0) + { + /* Move the cursor to after the last character in the + * buffer, so that word at start of buffer is found + * correctly. */ + first_match_pos.lnum = ins_buf->b_ml.ml_line_count; + first_match_pos.col = + (colnr_T)STRLEN(ml_get(first_match_pos.lnum)); + } last_match_pos = first_match_pos; type = 0; |