To: vim_dev@googlegroups.com Subject: Patch 8.1.0291 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.0291 Problem: 'incsearch' highlighting not used for :sort. Solution: Handle pattern in :sort command. Files: src/ex_getln.c, src/testdir/test_search.vim src/testdir/dumps/Test_incsearch_sort_01.dump *** ../vim-8.1.0290/src/ex_getln.c 2018-08-14 22:08:20.211616525 +0200 --- src/ex_getln.c 2018-08-18 16:02:12.989443789 +0200 *************** *** 316,321 **** --- 316,322 ---- && (STRNCMP(cmd, "substitute", p - cmd) == 0 || STRNCMP(cmd, "smagic", p - cmd) == 0 || STRNCMP(cmd, "snomagic", MAX(p - cmd, 3)) == 0 + || STRNCMP(cmd, "sort", p - cmd) == 0 || STRNCMP(cmd, "global", p - cmd) == 0 || STRNCMP(cmd, "vglobal", p - cmd) == 0)) { *************** *** 331,336 **** --- 332,347 ---- if (*skipwhite(p) == NUL) return FALSE; } + + // For ":sort" skip over flags. + if (cmd[0] == 's' && cmd[1] == 'o') + { + while (ASCII_ISALPHA(*(p = skipwhite(p)))) + ++p; + if (*p == NUL) + return FALSE; + } + p = skipwhite(p); delim = *p++; end = skip_regexp(p, delim, p_magic, NULL); *************** *** 359,365 **** search_last_line = ea.line2; } } ! else if (*cmd == 's') { // :s defaults to the current line search_first_line = curwin->w_cursor.lnum; --- 370,376 ---- search_last_line = ea.line2; } } ! else if (cmd[0] == 's' && cmd[1] != 'o') { // :s defaults to the current line search_first_line = curwin->w_cursor.lnum; *** ../vim-8.1.0290/src/testdir/test_search.vim 2018-08-14 21:32:17.618865046 +0200 --- src/testdir/test_search.vim 2018-08-18 16:03:40.248302161 +0200 *************** *** 917,922 **** --- 917,949 ---- call delete('Xis_subst_script') endfunc + " Similar to Test_incsearch_substitute_dump() for :sort + func Test_incsearch_ssort_dump() + if !exists('+incsearch') + return + endif + if !CanRunVimInTerminal() + return + endif + call writefile([ + \ 'set incsearch hlsearch scrolloff=0', + \ 'call setline(1, ["another one 2", "that one 3", "the one 1"])', + \ ], 'Xis_sort_script') + let buf = RunVimInTerminal('-S Xis_sort_script', {'rows': 9, 'cols': 70}) + " Give Vim a chance to redraw to get rid of the spaces in line 2 caused by + " the 'ambiwidth' check. + sleep 100m + + " Need to send one key at a time to force a redraw. + call term_sendkeys(buf, ':sort ni u /on') + sleep 100m + call VerifyScreenDump(buf, 'Test_incsearch_sort_01', {}) + call term_sendkeys(buf, "\") + + call StopVimInTerminal(buf) + call delete('Xis_sort_script') + endfunc + func Test_search_undefined_behaviour() if !has("terminal") return *** ../vim-8.1.0290/src/testdir/dumps/Test_incsearch_sort_01.dump 2018-08-18 16:10:12.014816068 +0200 --- src/testdir/dumps/Test_incsearch_sort_01.dump 2018-08-18 16:03:45.812228115 +0200 *************** *** 0 **** --- 1,9 ---- + |a+0&#ffffff0|n|o|t|h|e|r| |o+1&&|n|e+0&&| |2| @56 + |t|h|a|t| |o+0&#ffff4012|n|e+0&#ffffff0| |3| @59 + |t|h|e| |o+0&#ffff4012|n|e+0&#ffffff0| |1| @60 + |~+0#4040ff13&| @68 + |~| @68 + |~| @68 + |~| @68 + |~| @68 + |:+0#0000000&|s|o|r|t| |n|i| |u| |/|o|n> @55 *** ../vim-8.1.0290/src/version.c 2018-08-16 21:37:46.389318767 +0200 --- src/version.c 2018-08-18 16:09:14.599647949 +0200 *************** *** 796,797 **** --- 796,799 ---- { /* Add new patch number below this line */ + /**/ + 291, /**/ -- The MS-Windows registry is no more hostile than any other bunch of state information... that is held in a binary format... a format that nobody understands... and is replicated and cached in a complex and largely undocumented way... and contains large amounts of duplicate and obfuscated information... (Ben Peterson) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///