diff options
-rw-r--r-- | runtime/autoload/tutor.vim | 3 | ||||
-rw-r--r-- | src/nvim/charset.c | 11 | ||||
-rw-r--r-- | src/nvim/fileio.c | 2 | ||||
-rw-r--r-- | src/nvim/testdir/Makefile | 1 | ||||
-rw-r--r-- | src/nvim/testdir/test83-tags2 | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test83-tags3 | 102 | ||||
-rw-r--r-- | src/nvim/testdir/test83.in | 75 | ||||
-rw-r--r-- | src/nvim/testdir/test83.ok | 4 | ||||
-rw-r--r-- | src/nvim/window.c | 291 | ||||
-rw-r--r-- | test/functional/legacy/083_tag_search_with_file_encoding_spec.lua | 110 |
10 files changed, 271 insertions, 330 deletions
diff --git a/runtime/autoload/tutor.vim b/runtime/autoload/tutor.vim index 4d5a10a97c..43d8a87886 100644 --- a/runtime/autoload/tutor.vim +++ b/runtime/autoload/tutor.vim @@ -251,13 +251,14 @@ endfunction " Tutor Cmd: {{{1 function! s:Locale() - let l:lang = "" if exists('v:lang') && v:lang =~ '\a\a' let l:lang = v:lang elseif $LC_ALL =~ '\a\a' let l:lang = $LC_ALL elseif $LANG =~ '\a\a' let l:lang = $LANG + else + let l:lang = 'en_US' endif return split(l:lang, '_') endfunction diff --git a/src/nvim/charset.c b/src/nvim/charset.c index e0c9443511..9c63eca1f2 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -1791,7 +1791,6 @@ void vim_str2nr(char_u *start, int *prep, int *len, int pre = 0; // default is decimal int negative = false; unsigned long un = 0; - int n; if (ptr[0] == '-') { negative = true; @@ -1818,7 +1817,7 @@ void vim_str2nr(char_u *start, int *prep, int *len, if (dooct) { // Don't interpret "0", "08" or "0129" as octal. - for (n = 1; ascii_isdigit(ptr[n]); ++n) { + for (int n = 1; ascii_isdigit(ptr[n]); ++n) { if (ptr[n] > '7') { // can't be octal pre = 0; @@ -1836,9 +1835,6 @@ void vim_str2nr(char_u *start, int *prep, int *len, // Do the string-to-numeric conversion "manually" to avoid sscanf quirks. if ((pre == 'B') || (pre == 'b') || (dobin > 1)) { // bin - if (pre != 0) { - n += 2; // skip over "0b" - } while ('0' <= *ptr && *ptr <= '1') { un = 2 * un + (unsigned long)(*ptr - '0'); ptr++; @@ -1849,11 +1845,8 @@ void vim_str2nr(char_u *start, int *prep, int *len, un = 8 * un + (unsigned long)(*ptr - '0'); ptr++; } - } else if (pre != 0 || dohex > 1) { + } else if ((pre == 'X') || (pre == 'x') || dohex > 1) { // hex - if (pre != 0) { - n += 2; // skip over "0x" - } while (ascii_isxdigit(*ptr)) { un = 16 * un + (unsigned long)hex2nr(*ptr); ptr++; diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 26376afa27..c095a7d27f 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -6305,7 +6305,7 @@ bool has_event(int event) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT /// @param force When true, ignore autocmd_busy /// @param group autocmd group ID or AUGROUP_ALL /// @param buf Buffer for <abuf> -/// @param exarg Ex command arguments +/// @param eap Ex command arguments /// /// @return true if some commands were executed. static bool apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io, diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index aaa6f4b97e..e27ac227c8 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -22,7 +22,6 @@ SCRIPTS := test_eval.out \ test68.out test69.out \ test73.out \ test79.out \ - test83.out \ test88.out \ test_listlbr.out \ test_breakindent.out \ diff --git a/src/nvim/testdir/test83-tags2 b/src/nvim/testdir/test83-tags2 deleted file mode 100644 index 7f9f21b0eb..0000000000 --- a/src/nvim/testdir/test83-tags2 +++ /dev/null @@ -1,2 +0,0 @@ -!_TAG_FILE_ENCODING cp932 // -`ab Xtags2.txt /`ab diff --git a/src/nvim/testdir/test83-tags3 b/src/nvim/testdir/test83-tags3 deleted file mode 100644 index 0cb6591562..0000000000 --- a/src/nvim/testdir/test83-tags3 +++ /dev/null @@ -1,102 +0,0 @@ -!_TAG_FILE_SORTED 1 // -!_TAG_FILE_ENCODING cp932 // -abc1 Xtags3.txt /`ab -abc2 Xtags3.txt /`ab -abc3 Xtags3.txt /`ab -abc4 Xtags3.txt /`ab -abc5 Xtags3.txt /`ab -abc6 Xtags3.txt /`ab -abc7 Xtags3.txt /`ab -abc8 Xtags3.txt /`ab -abc9 Xtags3.txt /`ab -abc10 Xtags3.txt /`ab -abc11 Xtags3.txt /`ab -abc12 Xtags3.txt /`ab -abc13 Xtags3.txt /`ab -abc14 Xtags3.txt /`ab -abc15 Xtags3.txt /`ab -abc16 Xtags3.txt /`ab -abc17 Xtags3.txt /`ab -abc18 Xtags3.txt /`ab -abc19 Xtags3.txt /`ab -abc20 Xtags3.txt /`ab -abc21 Xtags3.txt /`ab -abc22 Xtags3.txt /`ab -abc23 Xtags3.txt /`ab -abc24 Xtags3.txt /`ab -abc25 Xtags3.txt /`ab -abc26 Xtags3.txt /`ab -abc27 Xtags3.txt /`ab -abc28 Xtags3.txt /`ab -abc29 Xtags3.txt /`ab -abc30 Xtags3.txt /`ab -abc31 Xtags3.txt /`ab -abc32 Xtags3.txt /`ab -abc33 Xtags3.txt /`ab -abc34 Xtags3.txt /`ab -abc35 Xtags3.txt /`ab -abc36 Xtags3.txt /`ab -abc37 Xtags3.txt /`ab -abc38 Xtags3.txt /`ab -abc39 Xtags3.txt /`ab -abc40 Xtags3.txt /`ab -abc41 Xtags3.txt /`ab -abc42 Xtags3.txt /`ab -abc43 Xtags3.txt /`ab -abc44 Xtags3.txt /`ab -abc45 Xtags3.txt /`ab -abc46 Xtags3.txt /`ab -abc47 Xtags3.txt /`ab -abc48 Xtags3.txt /`ab -abc49 Xtags3.txt /`ab -abc50 Xtags3.txt /`ab -abc51 Xtags3.txt /`ab -abc52 Xtags3.txt /`ab -abc53 Xtags3.txt /`ab -abc54 Xtags3.txt /`ab -abc55 Xtags3.txt /`ab -abc56 Xtags3.txt /`ab -abc57 Xtags3.txt /`ab -abc58 Xtags3.txt /`ab -abc59 Xtags3.txt /`ab -abc60 Xtags3.txt /`ab -abc61 Xtags3.txt /`ab -abc62 Xtags3.txt /`ab -abc63 Xtags3.txt /`ab -abc64 Xtags3.txt /`ab -abc65 Xtags3.txt /`ab -abc66 Xtags3.txt /`ab -abc67 Xtags3.txt /`ab -abc68 Xtags3.txt /`ab -abc69 Xtags3.txt /`ab -abc70 Xtags3.txt /`ab -abc71 Xtags3.txt /`ab -abc72 Xtags3.txt /`ab -abc73 Xtags3.txt /`ab -abc74 Xtags3.txt /`ab -abc75 Xtags3.txt /`ab -abc76 Xtags3.txt /`ab -abc77 Xtags3.txt /`ab -abc78 Xtags3.txt /`ab -abc79 Xtags3.txt /`ab -abc80 Xtags3.txt /`ab -abc81 Xtags3.txt /`ab -abc82 Xtags3.txt /`ab -abc83 Xtags3.txt /`ab -abc84 Xtags3.txt /`ab -abc85 Xtags3.txt /`ab -abc86 Xtags3.txt /`ab -abc87 Xtags3.txt /`ab -abc88 Xtags3.txt /`ab -abc89 Xtags3.txt /`ab -abc90 Xtags3.txt /`ab -abc91 Xtags3.txt /`ab -abc92 Xtags3.txt /`ab -abc93 Xtags3.txt /`ab -abc94 Xtags3.txt /`ab -abc95 Xtags3.txt /`ab -abc96 Xtags3.txt /`ab -abc97 Xtags3.txt /`ab -abc98 Xtags3.txt /`ab -abc99 Xtags3.txt /`ab -abc100 Xtags3.txt /`ab diff --git a/src/nvim/testdir/test83.in b/src/nvim/testdir/test83.in deleted file mode 100644 index d54b1bcddd..0000000000 --- a/src/nvim/testdir/test83.in +++ /dev/null @@ -1,75 +0,0 @@ -Tests for tag search with !_TAG_FILE_ENCODING. - -STARTTEST -:so mbyte.vim -:if !has('iconv') || iconv("\x82\x60", "cp932", "utf-8") != "\uff21" -: e! test.ok -: w! test.out -: qa! -:endif - -:/^text for tags1$/,/^text for tags1$/+1w! Xtags1.txt -:/^text for tags2$/,/^text for tags2$/+1w! Xtags2.txt -:/^text for tags3$/,/^text for tags3$/+1w! Xtags3.txt -:/^tags1$/+1,/^tags1-end$/-1w! Xtags1 - -ggdG - -:call setline('.', 'Results of test83') - -:" case1: -:new -:set tags=Xtags1 -:let v:errmsg = '' -:tag abcdefghijklmnopqrs -:if v:errmsg =~ 'E426:' || getline('.') != 'abcdefghijklmnopqrs' -: close -: put ='case1: failed' -:else -: close -: put ='case1: ok' -:endif - -:" case2: -:new -:set tags=test83-tags2 -:let v:errmsg = '' -:tag /.īŧĸīŧŖ -:if v:errmsg =~ 'E426:' || getline('.') != 'īŧĄīŧĸīŧŖ' -: close -: put ='case2: failed' -:else -: close -: put ='case2: ok' -:endif - -:" case3: -:new -:set tags=test83-tags3 -:let v:errmsg = '' -:tag abc50 -:if v:errmsg =~ 'E426:' || getline('.') != 'īŧĄīŧĸīŧŖ' -: close -: put ='case3: failed' -:else -: close -: put ='case3: ok' -:endif -:close - -:wq! test.out -ENDTEST - -text for tags1 -abcdefghijklmnopqrs - -text for tags2 -īŧĄīŧĸīŧŖ - -text for tags3 -īŧĄīŧĸīŧŖ - -tags1 -!_TAG_FILE_ENCODING utf-8 // -abcdefghijklmnopqrs Xtags1.txt /abcdefghijklmnopqrs -tags1-end diff --git a/src/nvim/testdir/test83.ok b/src/nvim/testdir/test83.ok deleted file mode 100644 index 61a1a04a18..0000000000 --- a/src/nvim/testdir/test83.ok +++ /dev/null @@ -1,4 +0,0 @@ -Results of test83 -case1: ok -case2: ok -case3: ok diff --git a/src/nvim/window.c b/src/nvim/window.c index f0c6cacdf0..853f8755c3 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1044,19 +1044,21 @@ static void win_init_some(win_T *newp, win_T *oldp) } -/* - * Check if "win" is a pointer to an existing window. - */ -int win_valid(win_T *win) +/// Check if "win" is a pointer to an existing window in the current tabpage. +/// +/// @param win window to check +bool win_valid(win_T *win) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT { - if (win == NULL) - return FALSE; + if (win == NULL) { + return false; + } + FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { if (wp == win) { - return TRUE; + return true; } } - return FALSE; + return false; } /* @@ -1732,21 +1734,18 @@ close_windows ( shell_new_rows(); } -/* - * Return TRUE if the current window is the only window that exists (ignoring - * "aucmd_win"). - * Returns FALSE if there is a window, possibly in another tab page. - */ -static int last_window(void) +/// Check that current window is the last one. +/// +/// @return true if the current window is the only window that exists, false if +/// there is another, possibly in another tab page. +static bool last_window(void) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT { return one_window() && first_tabpage->tp_next == NULL; } -/* - * Return TRUE if there is only one window other than "aucmd_win" in the - * current tab page. - */ -bool one_window(void) +/// Check that current tab page contains no more then one window other than +/// "aucmd_win". +bool one_window(void) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT { bool seen_one = false; @@ -1761,14 +1760,20 @@ bool one_window(void) return true; } -/* - * Close the possibly last window in a tab page. - * Returns TRUE when the window was closed already. - */ -static int close_last_window_tabpage(win_T *win, int free_buf, tabpage_T *prev_curtab) +/// Close the possibly last window in a tab page. +/// +/// @param win window to close +/// @param free_buf whether to free the window's current buffer +/// @param prev_curtab previous tabpage that will be closed if "win" is the +/// last window in the tabpage +/// +/// @return true when the window was closed already. +static bool close_last_window_tabpage(win_T *win, bool free_buf, + tabpage_T *prev_curtab) + FUNC_ATTR_NONNULL_ARG(1) { if (firstwin != lastwin) { - return FALSE; + return false; } buf_T *old_curbuf = curbuf; @@ -1809,14 +1814,15 @@ static int close_last_window_tabpage(win_T *win, int free_buf, tabpage_T *prev_c terminal_resize(term, 0, 0); } - /* Since goto_tabpage_tp above did not trigger *Enter autocommands, do - * that now. */ - apply_autocmds(EVENT_TABCLOSED, prev_idx, prev_idx, FALSE, curbuf); - apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf); - apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf); - if (old_curbuf != curbuf) - apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); - return TRUE; + // Since goto_tabpage_tp above did not trigger *Enter autocommands, do + // that now. + apply_autocmds(EVENT_TABCLOSED, prev_idx, prev_idx, false, curbuf); + apply_autocmds(EVENT_WINENTER, NULL, NULL, false, curbuf); + apply_autocmds(EVENT_TABENTER, NULL, NULL, false, curbuf); + if (old_curbuf != curbuf) { + apply_autocmds(EVENT_BUFENTER, NULL, NULL, false, curbuf); + } + return true; } /* @@ -2301,20 +2307,22 @@ static win_T *frame2win(frame_T *frp) return frp->fr_win; } -/* - * Return TRUE if frame "frp" contains window "wp". - */ -static int frame_has_win(frame_T *frp, win_T *wp) +/// Check that the frame "frp" contains the window "wp". +/// +/// @param frp frame +/// @param wp window +static bool frame_has_win(frame_T *frp, win_T *wp) + FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ARG(1) { - frame_T *p; - - if (frp->fr_layout == FR_LEAF) + if (frp->fr_layout == FR_LEAF) { return frp->fr_win == wp; - - for (p = frp->fr_child; p != NULL; p = p->fr_next) - if (frame_has_win(p, wp)) - return TRUE; - return FALSE; + } + for (frame_T *p = frp->fr_child; p != NULL; p = p->fr_next) { + if (frame_has_win(p, wp)) { + return true; + } + } + return false; } /* @@ -2406,58 +2414,72 @@ frame_new_height ( topfrp->fr_height = height; } -/* - * Return TRUE if height of frame "frp" should not be changed because of - * the 'winfixheight' option. - */ -static int frame_fixed_height(frame_T *frp) +/// Return true if height of frame "frp" should not be changed because of +/// the 'winfixheight' option. +/// +/// @param frp frame +/// +/// @return true if the frame has a fixed height +static bool frame_fixed_height(frame_T *frp) + FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { - /* frame with one window: fixed height if 'winfixheight' set. */ - if (frp->fr_win != NULL) + // frame with one window: fixed height if 'winfixheight' set. + if (frp->fr_win != NULL) { return frp->fr_win->w_p_wfh; - + } if (frp->fr_layout == FR_ROW) { - /* The frame is fixed height if one of the frames in the row is fixed - * height. */ - for (frp = frp->fr_child; frp != NULL; frp = frp->fr_next) - if (frame_fixed_height(frp)) - return TRUE; - return FALSE; + // The frame is fixed height if one of the frames in the row is fixed + // height. + for (frp = frp->fr_child; frp != NULL; frp = frp->fr_next) { + if (frame_fixed_height(frp)) { + return true; + } + } + return false; } - /* frp->fr_layout == FR_COL: The frame is fixed height if all of the - * frames in the row are fixed height. */ - for (frp = frp->fr_child; frp != NULL; frp = frp->fr_next) - if (!frame_fixed_height(frp)) - return FALSE; - return TRUE; + // frp->fr_layout == FR_COL: The frame is fixed height if all of the + // frames in the row are fixed height. + for (frp = frp->fr_child; frp != NULL; frp = frp->fr_next) { + if (!frame_fixed_height(frp)) { + return false; + } + } + return true; } -/* - * Return TRUE if width of frame "frp" should not be changed because of - * the 'winfixwidth' option. - */ -static int frame_fixed_width(frame_T *frp) +/// Return true if width of frame "frp" should not be changed because of +/// the 'winfixwidth' option. +/// +/// @param frp frame +/// +/// @return true if the frame has a fixed width +static bool frame_fixed_width(frame_T *frp) + FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { - /* frame with one window: fixed width if 'winfixwidth' set. */ - if (frp->fr_win != NULL) + // frame with one window: fixed width if 'winfixwidth' set. + if (frp->fr_win != NULL) { return frp->fr_win->w_p_wfw; - + } if (frp->fr_layout == FR_COL) { - /* The frame is fixed width if one of the frames in the row is fixed - * width. */ - for (frp = frp->fr_child; frp != NULL; frp = frp->fr_next) - if (frame_fixed_width(frp)) - return TRUE; - return FALSE; + // The frame is fixed width if one of the frames in the row is fixed + // width. + for (frp = frp->fr_child; frp != NULL; frp = frp->fr_next) { + if (frame_fixed_width(frp)) { + return true; + } + } + return false; } - /* frp->fr_layout == FR_ROW: The frame is fixed width if all of the - * frames in the row are fixed width. */ - for (frp = frp->fr_child; frp != NULL; frp = frp->fr_next) - if (!frame_fixed_width(frp)) - return FALSE; - return TRUE; + // frp->fr_layout == FR_ROW: The frame is fixed width if all of the + // frames in the row are fixed width. + for (frp = frp->fr_child; frp != NULL; frp = frp->fr_next) { + if (!frame_fixed_width(frp)) { + return false; + } + } + return true; } /* @@ -3028,10 +3050,10 @@ int make_tabpages(int maxcount) return count - todo; } -/* - * Return TRUE when "tpc" points to a valid tab page. - */ -bool valid_tabpage(tabpage_T *tpc) +/// Check that tpc points to a valid tab page. +/// +/// @param[in] tpc Tabpage to check. +bool valid_tabpage(tabpage_T *tpc) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT { FOR_ALL_TABS(tp) { if (tp == tpc) { @@ -5052,27 +5074,22 @@ int min_rows(void) return total; } -/* - * Return TRUE if there is only one window (in the current tab page), not - * counting a help or preview window, unless it is the current window. - * Does not count "aucmd_win". - */ -int only_one_window(void) +/// Check that there is only one window (and only one tab page), not counting a +/// help or preview window, unless it is the current window. Does not count +/// "aucmd_win". +bool only_one_window(void) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT { - int count = 0; - - /* If there is another tab page there always is another window. */ - if (first_tabpage->tp_next != NULL) - return FALSE; + // If there is another tab page there always is another window. + if (first_tabpage->tp_next != NULL) { + return false; + } + int count = 0; FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { if (wp->w_buffer != NULL && (!((wp->w_buffer->b_help && !curbuf->b_help) - || wp->w_p_pvw - ) || wp == curwin) - && wp != aucmd_win - ) { - ++count; + || wp->w_p_pvw) || wp == curwin) && wp != aucmd_win) { + count++; } } return count <= 1; @@ -5571,38 +5588,42 @@ matchitem_T *get_match(win_T *wp, int id) } -/* - * Return TRUE if "topfrp" and its children are at the right height. - */ -static int frame_check_height(frame_T *topfrp, int height) +/// Check that "topfrp" and its children are at the right height. +/// +/// @param topfrp top frame pointer +/// @param height expected height +static bool frame_check_height(frame_T *topfrp, int height) + FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { - frame_T *frp; - - if (topfrp->fr_height != height) - return FALSE; - - if (topfrp->fr_layout == FR_ROW) - for (frp = topfrp->fr_child; frp != NULL; frp = frp->fr_next) - if (frp->fr_height != height) - return FALSE; - - return TRUE; + if (topfrp->fr_height != height) { + return false; + } + if (topfrp->fr_layout == FR_ROW) { + for (frame_T *frp = topfrp->fr_child; frp != NULL; frp = frp->fr_next) { + if (frp->fr_height != height) { + return false; + } + } + } + return true; } -/* - * Return TRUE if "topfrp" and its children are at the right width. - */ -static int frame_check_width(frame_T *topfrp, int width) +/// Check that "topfrp" and its children are at the right width. +/// +/// @param topfrp top frame pointer +/// @param width expected width +static bool frame_check_width(frame_T *topfrp, int width) + FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { - frame_T *frp; - - if (topfrp->fr_width != width) - return FALSE; - - if (topfrp->fr_layout == FR_COL) - for (frp = topfrp->fr_child; frp != NULL; frp = frp->fr_next) - if (frp->fr_width != width) - return FALSE; - - return TRUE; + if (topfrp->fr_width != width) { + return false; + } + if (topfrp->fr_layout == FR_COL) { + for (frame_T *frp = topfrp->fr_child; frp != NULL; frp = frp->fr_next) { + if (frp->fr_width != width) { + return false; + } + } + } + return true; } diff --git a/test/functional/legacy/083_tag_search_with_file_encoding_spec.lua b/test/functional/legacy/083_tag_search_with_file_encoding_spec.lua new file mode 100644 index 0000000000..dc6df007e6 --- /dev/null +++ b/test/functional/legacy/083_tag_search_with_file_encoding_spec.lua @@ -0,0 +1,110 @@ +-- Tests for tag search with !_TAG_FILE_ENCODING. + +local helpers = require('test.functional.helpers') +local insert, source, clear, expect, write_file = helpers.insert, + helpers.source, helpers.clear, helpers.expect, helpers.write_file + +local function has_iconv() + clear() -- ensures session + return 1 == helpers.eval('has("iconv")') +end + +describe('tag search with !_TAG_FILE_ENCODING', function() + setup(function() + clear() + -- Create some temp files that are needed for the test run. In the old + -- test suite this was done by putting the text inside the file test83.in + -- and executing some "/first/,/last/w! tmpfile" commands. + write_file('Xtags1.txt', 'text for tags1\nabcdefghijklmnopqrs\n') + write_file('Xtags2.txt', 'text for tags2\nīŧĄīŧĸīŧŖ\n') + write_file('Xtags3.txt', 'text for tags3\nīŧĄīŧĸīŧŖ\n') + write_file('Xtags1', [[ + !_TAG_FILE_ENCODING utf-8 // + abcdefghijklmnopqrs Xtags1.txt /abcdefghijklmnopqrs + ]]) + write_file('test83-tags2', + '!_TAG_FILE_ENCODING cp932 //\n' .. + '\x82`\x82a\x82b Xtags2.txt /\x82`\x82a\x82b\n' + ) + -- The last file is very long but repetetive and can be generated on the + -- fly. + local text = helpers.dedent([[ + !_TAG_FILE_SORTED 1 // + !_TAG_FILE_ENCODING cp932 // + ]]) + local line = ' Xtags3.txt /\x82`\x82a\x82b\n' + for i = 1, 100 do + text = text .. 'abc' .. i .. line + end + write_file('test83-tags3', text) + end) + teardown(function() + os.remove('Xtags1') + os.remove('Xtags1.txt') + os.remove('Xtags2.txt') + os.remove('Xtags3.txt') + os.remove('test83-tags2') + os.remove('test83-tags3') + end) + + if not has_iconv() then + pending('skipped (missing iconv)', function() end) + else + it('is working', function() + + insert('Results of test83') + + -- Case1: + source([[ + new + set tags=Xtags1 + let v:errmsg = '' + tag abcdefghijklmnopqrs + if v:errmsg =~ 'E426:' || getline('.') != 'abcdefghijklmnopqrs' + close + put ='case1: failed' + else + close + put ='case1: ok' + endif + ]]) + + -- Case2: + source([[ + new + set tags=test83-tags2 + let v:errmsg = '' + tag /.īŧĸīŧŖ + if v:errmsg =~ 'E426:' || getline('.') != 'īŧĄīŧĸīŧŖ' + close + put ='case2: failed' + else + close + put ='case2: ok' + endif + ]]) + + -- Case3: + source([[ + new + set tags=test83-tags3 + let v:errmsg = '' + tag abc50 + if v:errmsg =~ 'E426:' || getline('.') != 'īŧĄīŧĸīŧŖ' + close + put ='case3: failed' + else + close + put ='case3: ok' + endif + ]]) + + -- Assert buffer contents. + expect([[ + Results of test83 + case1: ok + case2: ok + case3: ok]]) + end) + end +end) |