diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/nvim/CMakeLists.txt | 12 | ||||
| -rw-r--r-- | src/nvim/edit.c | 2 | ||||
| -rw-r--r-- | src/nvim/eval.c | 4 | ||||
| -rw-r--r-- | src/nvim/mbyte.c | 19 | ||||
| -rw-r--r-- | src/nvim/option.c | 30 | ||||
| -rw-r--r-- | src/nvim/option_defs.h | 37 | ||||
| -rw-r--r-- | src/nvim/options.lua | 8 | ||||
| -rw-r--r-- | src/nvim/testdir/test_popup.vim | 35 | ||||
| -rw-r--r-- | src/nvim/ui.c | 5 | ||||
| -rw-r--r-- | src/nvim/version.c | 14 |
10 files changed, 110 insertions, 56 deletions
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 7c2c2feebc..59582d0734 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -36,9 +36,7 @@ set(EVAL_DEFS_FILE ${PROJECT_SOURCE_DIR}/src/nvim/eval.lua) set(OPTIONS_LIST_FILE ${PROJECT_SOURCE_DIR}/src/nvim/options.lua) set(UNICODE_TABLES_GENERATOR ${PROJECT_SOURCE_DIR}/scripts/genunicodetables.lua) set(UNICODE_DIR ${PROJECT_SOURCE_DIR}/unicode) -set(UNICODEDATA_FILE ${UNICODE_DIR}/UnicodeData.txt) -set(CASEFOLDING_FILE ${UNICODE_DIR}/CaseFolding.txt) -set(EASTASIANWIDTH_FILE ${UNICODE_DIR}/EastAsianWidth.txt) +file(GLOB UNICODE_FILES ${UNICODE_DIR}/*.txt) set(GENERATED_UNICODE_TABLES ${GENERATED_DIR}/unicode_tables.generated.h) include_directories(${GENERATED_DIR}) @@ -192,15 +190,11 @@ endforeach() add_custom_command(OUTPUT ${GENERATED_UNICODE_TABLES} COMMAND ${LUA_PRG} ${UNICODE_TABLES_GENERATOR} - ${UNICODEDATA_FILE} - ${CASEFOLDING_FILE} - ${EASTASIANWIDTH_FILE} + ${UNICODE_DIR} ${GENERATED_UNICODE_TABLES} DEPENDS ${UNICODE_TABLES_GENERATOR} - ${UNICODEDATA_FILE} - ${CASEFOLDING_FILE} - ${EASTASIANWIDTH_FILE} + ${UNICODE_FILES} ) add_custom_command(OUTPUT ${GENERATED_API_DISPATCH} ${API_METADATA} diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 18d5ea533d..ca5b6f02ce 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -502,7 +502,7 @@ static int insert_check(VimState *state) Insstart_orig = Insstart; } - if (stop_insert_mode) { + if (stop_insert_mode && !pum_visible()) { // ":stopinsert" used or 'insertmode' reset s->count = 0; return 0; // exit insert mode diff --git a/src/nvim/eval.c b/src/nvim/eval.c index c762ce9fff..7d7aea83af 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -2684,6 +2684,10 @@ void set_context_for_expression(expand_T *xp, char_u *arg, cmdidx_T cmdidx) } else if (c == '=') { got_eq = TRUE; xp->xp_context = EXPAND_EXPRESSION; + } else if (c == '#' + && xp->xp_context == EXPAND_EXPRESSION) { + // Autoload function/variable contains '#' + break; } else if ((c == '<' || c == '#') && xp->xp_context == EXPAND_FUNCTIONS && vim_strchr(xp->xp_pattern, '(') == NULL) { diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index f577fd847e..c08b9e8fcf 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -949,6 +949,9 @@ int utf_char2cells(int c) if (intable(doublewidth, ARRAY_SIZE(doublewidth), c)) return 2; #endif + if (p_emoji && intable(emoji_width, ARRAY_SIZE(emoji_width), c)) { + return 2; + } } /* Characters below 0x100 are influenced by 'isprint' option */ else if (c >= 0x80 && !vim_isprintc(c)) @@ -1712,16 +1715,20 @@ int utf_class(int c) return (int)classes[mid].class; } + // emoji + if (intable(emoji_all, ARRAY_SIZE(emoji_all), c)) { + return 3; + } + /* most other characters are "word" characters */ return 2; } -/* - * Code for Unicode case-dependent operations. Based on notes in - * http://www.unicode.org/Public/UNIDATA/CaseFolding.txt - * This code uses simple case folding, not full case folding. - * Last updated for Unicode 5.2. - */ +int utf_ambiguous_width(int c) +{ + return c >= 0x80 && (intable(ambiguous, ARRAY_SIZE(ambiguous), c) + || intable(emoji_all, ARRAY_SIZE(emoji_all), c)); +} /* * Generic conversion function for case operations. diff --git a/src/nvim/option.c b/src/nvim/option.c index d8908cca90..e2a5d38bee 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2518,15 +2518,15 @@ did_set_string_option ( else if (varp == &p_sbo) { if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK) errmsg = e_invarg; - } - /* 'ambiwidth' */ - else if (varp == &p_ambw) { - if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK) + } else if (varp == &p_ambw || (bool *)varp == &p_emoji) { + // 'ambiwidth' + if (check_opt_strings(p_ambw, p_ambw_values, false) != OK) { errmsg = e_invarg; - else if (set_chars_option(&p_lcs) != NULL) + } else if (set_chars_option(&p_lcs) != NULL) { errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'"); - else if (set_chars_option(&p_fcs) != NULL) + } else if (set_chars_option(&p_fcs) != NULL) { errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'"); + } } /* 'background' */ else if (varp == &p_bg) { @@ -3658,14 +3658,16 @@ set_bool_option ( /* when 'insertmode' is set from an autocommand need to do work here */ else if ((int *)varp == &p_im) { if (p_im) { - if ((State & INSERT) == 0) - need_start_insertmode = TRUE; - stop_insert_mode = FALSE; - } else { - need_start_insertmode = FALSE; - stop_insert_mode = TRUE; - if (restart_edit != 0 && mode_displayed) - clear_cmdline = TRUE; /* remove "(insert)" */ + if ((State & INSERT) == 0) { + need_start_insertmode = true; + } + stop_insert_mode = false; + } else if (old_value) { // only reset if it was set previously + need_start_insertmode = false; + stop_insert_mode = true; + if (restart_edit != 0 && mode_displayed) { + clear_cmdline = true; // remove "(insert)" + } restart_edit = 0; } } diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index e36cceaaf4..e085b973ea 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -401,24 +401,25 @@ static char *(p_dy_values[]) = {"lastline", "uhex", NULL}; #endif #define DY_LASTLINE 0x001 #define DY_UHEX 0x002 -EXTERN int p_ed; /* 'edcompatible' */ -EXTERN char_u *p_ead; /* 'eadirection' */ -EXTERN bool p_ea; /* 'equalalways' */ -EXTERN char_u *p_ep; /* 'equalprg' */ -EXTERN int p_eb; /* 'errorbells' */ -EXTERN char_u *p_ef; /* 'errorfile' */ -EXTERN char_u *p_efm; /* 'errorformat' */ -EXTERN char_u *p_gefm; /* 'grepformat' */ -EXTERN char_u *p_gp; /* 'grepprg' */ -EXTERN char_u *p_ei; /* 'eventignore' */ -EXTERN int p_ek; /* 'esckeys' */ -EXTERN int p_exrc; /* 'exrc' */ -EXTERN char_u *p_fencs; /* 'fileencodings' */ -EXTERN char_u *p_ffs; /* 'fileformats' */ -EXTERN bool p_fic; ///< 'fileignorecase' -EXTERN char_u *p_fcl; /* 'foldclose' */ -EXTERN long p_fdls; /* 'foldlevelstart' */ -EXTERN char_u *p_fdo; /* 'foldopen' */ +EXTERN int p_ed; // 'edcompatible' +EXTERN bool p_emoji; // 'emoji' +EXTERN char_u *p_ead; // 'eadirection' +EXTERN bool p_ea; // 'equalalways' +EXTERN char_u *p_ep; // 'equalprg' +EXTERN int p_eb; // 'errorbells' +EXTERN char_u *p_ef; // 'errorfile' +EXTERN char_u *p_efm; // 'errorformat' +EXTERN char_u *p_gefm; // 'grepformat' +EXTERN char_u *p_gp; // 'grepprg' +EXTERN char_u *p_ei; // 'eventignore' +EXTERN int p_ek; // 'esckeys' +EXTERN int p_exrc; // 'exrc' +EXTERN char_u *p_fencs; // 'fileencodings' +EXTERN char_u *p_ffs; // 'fileformats' +EXTERN bool p_fic; // 'fileignorecase' +EXTERN char_u *p_fcl; // 'foldclose' +EXTERN long p_fdls; // 'foldlevelstart' +EXTERN char_u *p_fdo; // 'foldopen' EXTERN unsigned fdo_flags; # ifdef IN_OPTION_C static char *(p_fdo_values[]) = {"all", "block", "hor", "mark", "percent", diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 060ec8c1e1..583c63614a 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -644,6 +644,14 @@ return { defaults={if_true={vi=false}} }, { + full_name='emoji', abbreviation='emo', + type='bool', scope={'global'}, + vi_def=true, + redraw={'everything'}, + varname='p_emoji', + defaults={if_true={vi=true}} + }, + { full_name='encoding', abbreviation='enc', type='string', scope={'global'}, deny_in_modelines=true, diff --git a/src/nvim/testdir/test_popup.vim b/src/nvim/testdir/test_popup.vim index 78fc81e3d2..63be8bf609 100644 --- a/src/nvim/testdir/test_popup.vim +++ b/src/nvim/testdir/test_popup.vim @@ -28,3 +28,38 @@ func Test_noinsert_complete() set completeopt-=noinsert iunmap <F5> endfunc + +let g:months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] +let g:setting = '' + +func ListMonths() + if g:setting != '' + exe ":set" g:setting + endif + call complete(col('.'), g:months) + return '' +endfunc + +func! Test_popup_completion_insertmode() + inoremap <F5> <C-R>=ListMonths()<CR> + new + call feedkeys("a\<F5>\<down>\<enter>\<esc>", 'tx') + call assert_equal('February', getline(1)) + %d + let g:setting = 'noinsertmode' + call feedkeys("a\<F5>\<down>\<enter>\<esc>", 'tx') + call assert_equal('February', getline(1)) + call assert_false(pumvisible()) + %d + let g:setting = '' + call feedkeys("a\<F5>". repeat("\<c-n>",12)."\<enter>\<esc>", 'tx') + call assert_equal('', getline(1)) + %d + call feedkeys("a\<F5>\<c-p>\<enter>\<esc>", 'tx') + call assert_equal('', getline(1)) + %d + call feedkeys("a\<F5>\<c-p>\<c-p>\<enter>\<esc>", 'tx') + call assert_equal('December', getline(1)) + bwipe! + iunmap <F5> +endfunc diff --git a/src/nvim/ui.c b/src/nvim/ui.c index b8d44cbcf8..648d633e07 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -397,7 +397,10 @@ static void send_output(uint8_t **ptr) size_t clen = (size_t)mb_ptr2len(p); UI_CALL(put, p, (size_t)clen); col++; - if (mb_ptr2cells(p) > 1) { + if (utf_ambiguous_width(*p)) { + pending_cursor_update = true; + flush_cursor_update(); + } else if (mb_ptr2cells(p) > 1) { // double cell character, blank the next cell UI_CALL(put, NULL, 0); col++; diff --git a/src/nvim/version.c b/src/nvim/version.c index 657afdd5e0..3f11c7e860 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -480,7 +480,7 @@ static int included_patches[] = { // 1964, // 1963 NA // 1962, - // 1961, + 1961, 1960, // 1959 NA // 1958 NA @@ -773,7 +773,7 @@ static int included_patches[] = { 1673, // 1672 NA 1671, - // 1670, + 1670, // 1669 NA // 1668 NA // 1667 NA @@ -801,7 +801,7 @@ static int included_patches[] = { // 1645, // 1644, 1643, - // 1642, + 1642, 1641, // 1640, // 1639, @@ -813,8 +813,8 @@ static int included_patches[] = { // 1633 NA // 1632 NA // 1631 NA - // 1630, - // 1629, + 1630, + 1629, // 1628 NA // 1627 NA // 1626 NA @@ -823,7 +823,7 @@ static int included_patches[] = { // 1623 NA // 1622 NA // 1621 NA - // 1620, + 1620, // 1619, // 1618 NA // 1617 NA @@ -839,7 +839,7 @@ static int included_patches[] = { // 1607, // 1606, // 1605, - // 1604, + 1604, 1603, // 1602 NA // 1601 NA |
