Compare commits

...

6 Commits

Author SHA1 Message Date
Bram Moolenaar
8822744b4d patch 8.0.0206: test coverage for :retab insufficient
Problem:    Test coverage for :retab insufficient.
Solution:   Add test for :retab. (Dominique Pelle, closes #1391)
2017-01-17 22:16:00 +01:00
Bram Moolenaar
5e4e1b1299 patch 8.0.0205: wrong behavior after :undojoin
Problem:    After :undojoin some commands don't work properly, such as :redo.
            (Matthew Malcomson)
Solution:   Don't set curbuf->b_u_curhead. (closes #1390)
2017-01-17 22:09:45 +01:00
Bram Moolenaar
eb46f8fa14 patch 8.0.0204: compiler warns for uninitialized variable
Problem:    Compiler warns for uninitialized variable. (Tony Mechelynck)
Solution:   When skipping set "id" to -1.
2017-01-17 19:48:53 +01:00
Bram Moolenaar
6e78e27b8a patch 8.0.0203: order of complication flags is sometimes wrong
Problem:    Order of complication flags is sometimes wrong.
Solution:   Put interface-specific flags before ALL_CFLAGS. (idea by Yousong
            Zhou, closes #1100)
2017-01-17 19:20:15 +01:00
Bram Moolenaar
4007ed4a5e patch 8.0.0202: no test for invalid syntax group name
Problem:    No test for invalid syntax group name.
Solution:   Add a test for group name error and warning.
2017-01-17 18:14:54 +01:00
Bram Moolenaar
d61e8aaae5 patch 8.0.0201: completion of highlight groups includes cleared names
Problem:    When completing a group name for a highlight or syntax command
            cleared groups are included.
Solution:   Skip groups that have been cleared.
2017-01-17 17:44:46 +01:00
8 changed files with 164 additions and 27 deletions

View File

@@ -1877,7 +1877,9 @@ myself:
# The normal command to compile a .c file to its .o file. # The normal command to compile a .c file to its .o file.
CCC = $(CC) -c -I$(srcdir) $(ALL_CFLAGS) # Without or with ALL_CFLAGS.
CCC_NF = $(CC) -c -I$(srcdir)
CCC = $(CCC_NF) $(ALL_CFLAGS)
# Link the target for normal use or debugging. # Link the target for normal use or debugging.
@@ -2152,6 +2154,7 @@ test_arglist \
test_regexp_latin \ test_regexp_latin \
test_regexp_utf8 \ test_regexp_utf8 \
test_reltime \ test_reltime \
test_retab \
test_ruby \ test_ruby \
test_search \ test_search \
test_searchpos \ test_searchpos \
@@ -2976,7 +2979,7 @@ objects/gui_gtk_f.o: gui_gtk_f.c
$(CCC) -o $@ gui_gtk_f.c $(CCC) -o $@ gui_gtk_f.c
objects/gui_gtk_gresources.o: auto/gui_gtk_gresources.c objects/gui_gtk_gresources.o: auto/gui_gtk_gresources.c
$(CCC) $(PERL_CFLAGS) -o $@ auto/gui_gtk_gresources.c $(CCC_NF) $(PERL_CFLAGS) $(ALL_CFLAGS) -o $@ auto/gui_gtk_gresources.c
objects/gui_gtk_x11.o: gui_gtk_x11.c objects/gui_gtk_x11.o: gui_gtk_x11.c
$(CCC) -o $@ gui_gtk_x11.c $(CCC) -o $@ gui_gtk_x11.c
@@ -3009,7 +3012,7 @@ objects/if_xcmdsrv.o: if_xcmdsrv.c
$(CCC) -o $@ if_xcmdsrv.c $(CCC) -o $@ if_xcmdsrv.c
objects/if_lua.o: if_lua.c objects/if_lua.o: if_lua.c
$(CCC) $(LUA_CFLAGS) -o $@ if_lua.c $(CCC_NF) $(LUA_CFLAGS) $(ALL_CFLAGS) -o $@ if_lua.c
objects/if_mzsch.o: if_mzsch.c $(MZSCHEME_EXTRA) objects/if_mzsch.o: if_mzsch.c $(MZSCHEME_EXTRA)
$(CCC) -o $@ $(MZSCHEME_CFLAGS_EXTRA) if_mzsch.c $(CCC) -o $@ $(MZSCHEME_CFLAGS_EXTRA) if_mzsch.c
@@ -3018,27 +3021,28 @@ mzscheme_base.c:
$(MZSCHEME_MZC) --c-mods mzscheme_base.c ++lib scheme/base $(MZSCHEME_MZC) --c-mods mzscheme_base.c ++lib scheme/base
objects/if_perl.o: auto/if_perl.c objects/if_perl.o: auto/if_perl.c
$(CCC) $(PERL_CFLAGS) -o $@ auto/if_perl.c $(CCC_NF) $(PERL_CFLAGS) $(ALL_CFLAGS) -o $@ auto/if_perl.c
objects/if_perlsfio.o: if_perlsfio.c objects/if_perlsfio.o: if_perlsfio.c
$(CCC) $(PERL_CFLAGS) -o $@ if_perlsfio.c $(CCC_NF) $(PERL_CFLAGS) $(ALL_CFLAGS) -o $@ if_perlsfio.c
objects/py_getpath.o: $(PYTHON_CONFDIR)/getpath.c objects/py_getpath.o: $(PYTHON_CONFDIR)/getpath.c
$(CCC) $(PYTHON_CFLAGS) -o $@ $(PYTHON_CONFDIR)/getpath.c \ $(CCC_NF) $(PYTHON_CFLAGS) $(ALL_CFLAGS) -o $@ \
$(PYTHON_CONFDIR)/getpath.c \
-I$(PYTHON_CONFDIR) -DHAVE_CONFIG_H -DNO_MAIN \ -I$(PYTHON_CONFDIR) -DHAVE_CONFIG_H -DNO_MAIN \
$(PYTHON_GETPATH_CFLAGS) $(PYTHON_GETPATH_CFLAGS)
objects/if_python.o: if_python.c if_py_both.h objects/if_python.o: if_python.c if_py_both.h
$(CCC) $(PYTHON_CFLAGS) $(PYTHON_CFLAGS_EXTRA) -o $@ if_python.c $(CCC_NF) $(PYTHON_CFLAGS) $(PYTHON_CFLAGS_EXTRA) $(ALL_CFLAGS) -o $@ if_python.c
objects/if_python3.o: if_python3.c if_py_both.h objects/if_python3.o: if_python3.c if_py_both.h
$(CCC) $(PYTHON3_CFLAGS) $(PYTHON3_CFLAGS_EXTRA) -o $@ if_python3.c $(CCC_NF) $(PYTHON3_CFLAGS) $(PYTHON3_CFLAGS_EXTRA) $(ALL_CFLAGS) -o $@ if_python3.c
objects/if_ruby.o: if_ruby.c objects/if_ruby.o: if_ruby.c
$(CCC) $(RUBY_CFLAGS) -o $@ if_ruby.c $(CCC_NF) $(RUBY_CFLAGS) $(ALL_CFLAGS) -o $@ if_ruby.c
objects/if_tcl.o: if_tcl.c objects/if_tcl.o: if_tcl.c
$(CCC) $(TCL_CFLAGS) -o $@ if_tcl.c $(CCC_NF) $(TCL_CFLAGS) $(ALL_CFLAGS) -o $@ if_tcl.c
objects/integration.o: integration.c objects/integration.o: integration.c
$(CCC) -o $@ integration.c $(CCC) -o $@ integration.c
@@ -3095,7 +3099,7 @@ objects/ops.o: ops.c
$(CCC) -o $@ ops.c $(CCC) -o $@ ops.c
objects/option.o: option.c objects/option.o: option.c
$(CCC) $(LUA_CFLAGS) $(PERL_CFLAGS) $(PYTHON_CFLAGS) $(PYTHON3_CFLAGS) $(RUBY_CFLAGS) $(TCL_CFLAGS) -o $@ option.c $(CCC_NF) $(LUA_CFLAGS) $(PERL_CFLAGS) $(PYTHON_CFLAGS) $(PYTHON3_CFLAGS) $(RUBY_CFLAGS) $(TCL_CFLAGS) $(ALL_CFLAGS) -o $@ option.c
objects/os_beos.o: os_beos.c objects/os_beos.o: os_beos.c
$(CCC) -o $@ os_beos.c $(CCC) -o $@ os_beos.c

View File

@@ -22,6 +22,7 @@ struct hl_group
{ {
char_u *sg_name; /* highlight group name */ char_u *sg_name; /* highlight group name */
char_u *sg_name_u; /* uppercase of sg_name */ char_u *sg_name_u; /* uppercase of sg_name */
int sg_cleared; /* "hi clear" was used */
/* for normal terminals */ /* for normal terminals */
int sg_term; /* "term=" highlighting attributes */ int sg_term; /* "term=" highlighting attributes */
char_u *sg_start; /* terminal string for start highl */ char_u *sg_start; /* terminal string for start highl */
@@ -6048,7 +6049,9 @@ get_id_list(
} }
else if (name[1] == '@') else if (name[1] == '@')
{ {
if (!skip) if (skip)
id = -1;
else
id = syn_check_cluster(name + 2, (int)(end - p - 1)); id = syn_check_cluster(name + 2, (int)(end - p - 1));
} }
else else
@@ -7327,6 +7330,7 @@ do_highlight(
#ifdef FEAT_EVAL #ifdef FEAT_EVAL
HL_TABLE()[from_id - 1].sg_scriptID = current_SID; HL_TABLE()[from_id - 1].sg_scriptID = current_SID;
#endif #endif
HL_TABLE()[from_id - 1].sg_cleared = FALSE;
redraw_all_later(SOME_VALID); redraw_all_later(SOME_VALID);
} }
} }
@@ -8034,6 +8038,7 @@ do_highlight(
error = TRUE; error = TRUE;
break; break;
} }
HL_TABLE()[idx].sg_cleared = FALSE;
/* /*
* When highlighting has been given for a group, don't link it. * When highlighting has been given for a group, don't link it.
@@ -8171,6 +8176,8 @@ hl_has_settings(int idx, int check_link)
static void static void
highlight_clear(int idx) highlight_clear(int idx)
{ {
HL_TABLE()[idx].sg_cleared = TRUE;
HL_TABLE()[idx].sg_term = 0; HL_TABLE()[idx].sg_term = 0;
vim_free(HL_TABLE()[idx].sg_start); vim_free(HL_TABLE()[idx].sg_start);
HL_TABLE()[idx].sg_start = NULL; HL_TABLE()[idx].sg_start = NULL;
@@ -9958,7 +9965,13 @@ get_highlight_name(expand_T *xp UNUSED, int idx)
&& include_link != 0) && include_link != 0)
return (char_u *)"clear"; return (char_u *)"clear";
#endif #endif
if (idx < 0 || idx >= highlight_ga.ga_len) if (idx < 0)
return NULL;
/* Items are never removed from the table, skip the ones that were cleared.
*/
while (idx < highlight_ga.ga_len && HL_TABLE()[idx].sg_cleared)
++idx;
if (idx >= highlight_ga.ga_len)
return NULL; return NULL;
return HL_TABLE()[idx].sg_name; return HL_TABLE()[idx].sg_name;
} }

View File

@@ -177,6 +177,7 @@ NEW_TESTS = test_arglist.res \
test_perl.res \ test_perl.res \
test_profile.res \ test_profile.res \
test_quickfix.res \ test_quickfix.res \
test_retab.res \
test_ruby.res \ test_ruby.res \
test_search.res \ test_search.res \
test_signs.res \ test_signs.res \

View File

@@ -0,0 +1,77 @@
" Test :retab
func SetUp()
new
call setline(1, "\ta \t b c ")
endfunc
func TearDown()
bwipe!
endfunc
func Retab(bang, n)
let l:old_tabstop = &tabstop
let l:old_line = getline(1)
exe "retab" . a:bang . a:n
let l:line = getline(1)
call setline(1, l:old_line)
if a:n > 0
" :retab changes 'tabstop' to n with argument n > 0.
call assert_equal(a:n, &tabstop)
exe 'set tabstop=' . l:old_tabstop
else
" :retab does not change 'tabstop' with empty or n <= 0.
call assert_equal(l:old_tabstop, &tabstop)
endif
return l:line
endfunc
func Test_retab()
set tabstop=8 noexpandtab
call assert_equal("\ta\t b c ", Retab('', ''))
call assert_equal("\ta\t b c ", Retab('', 0))
call assert_equal("\ta\t b c ", Retab('', 8))
call assert_equal("\ta\t b\t c\t ", Retab('!', ''))
call assert_equal("\ta\t b\t c\t ", Retab('!', 0))
call assert_equal("\ta\t b\t c\t ", Retab('!', 8))
call assert_equal("\t\ta\t\t\tb c ", Retab('', 4))
call assert_equal("\t\ta\t\t\tb\t\t c\t ", Retab('!', 4))
call assert_equal(" a\t\tb c ", Retab('', 10))
call assert_equal(" a\t\tb c ", Retab('!', 10))
set tabstop=8 expandtab
call assert_equal(" a b c ", Retab('', ''))
call assert_equal(" a b c ", Retab('', 0))
call assert_equal(" a b c ", Retab('', 8))
call assert_equal(" a b c ", Retab('!', ''))
call assert_equal(" a b c ", Retab('!', 0))
call assert_equal(" a b c ", Retab('!', 8))
call assert_equal(" a b c ", Retab(' ', 4))
call assert_equal(" a b c ", Retab('!', 4))
call assert_equal(" a b c ", Retab(' ', 10))
call assert_equal(" a b c ", Retab('!', 10))
set tabstop=4 noexpandtab
call assert_equal("\ta\t\tb c ", Retab('', ''))
call assert_equal("\ta\t\tb\t\t c\t ", Retab('!', ''))
call assert_equal("\t a\t\t\tb c ", Retab('', 3))
call assert_equal("\t a\t\t\tb\t\t\tc\t ", Retab('!', 3))
call assert_equal(" a\t b c ", Retab('', 5))
call assert_equal(" a\t b\t\t c\t ", Retab('!', 5))
set tabstop=4 expandtab
call assert_equal(" a b c ", Retab('', ''))
call assert_equal(" a b c ", Retab('!', ''))
call assert_equal(" a b c ", Retab('', 3))
call assert_equal(" a b c ", Retab('!', 3))
call assert_equal(" a b c ", Retab('', 5))
call assert_equal(" a b c ", Retab('!', 5))
endfunc
func Test_retab_error()
call assert_fails('retab -1', 'E487:')
call assert_fails('retab! -1', 'E487:')
endfunc

View File

@@ -156,6 +156,12 @@ func Test_syntax_completion()
call feedkeys(":syn sync \<C-A>\<C-B>\"\<CR>", 'tx') call feedkeys(":syn sync \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"syn sync ccomment clear fromstart linebreaks= linecont lines= match maxlines= minlines= region', @:) call assert_equal('"syn sync ccomment clear fromstart linebreaks= linecont lines= match maxlines= minlines= region', @:)
" Check that clearing "Aap" avoids it showing up before Boolean.
hi Aap ctermfg=blue
call feedkeys(":syn list \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_match('^"syn list Aap Boolean Character ', @:)
hi clear Aap
call feedkeys(":syn list \<C-A>\<C-B>\"\<CR>", 'tx') call feedkeys(":syn list \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_match('^"syn list Boolean Character ', @:) call assert_match('^"syn list Boolean Character ', @:)
@@ -192,11 +198,11 @@ func Test_syntax_arg_skipped()
call assert_match('conceal off', execute('syntax conceal')) call assert_match('conceal off', execute('syntax conceal'))
endif endif
syntax region Tar start=/</ end=/>/ syntax region Bar start=/</ end=/>/
if 0 if 0
syntax region NotTest start=/</ end=/>/ contains=@Spell syntax region NotTest start=/</ end=/>/ contains=@Spell
endif endif
call assert_match('Tar', execute('syntax')) call assert_match('Bar', execute('syntax'))
call assert_notmatch('NotTest', execute('syntax')) call assert_notmatch('NotTest', execute('syntax'))
call assert_notmatch('Spell', execute('syntax')) call assert_notmatch('Spell', execute('syntax'))
@@ -206,6 +212,8 @@ func Test_syntax_arg_skipped()
syntax rest syntax rest
endif endif
call assert_equal(a, execute('hi Foo')) call assert_equal(a, execute('hi Foo'))
hi clear Bar
hi clear Foo
set ft=tags set ft=tags
syn off syn off
@@ -298,7 +306,9 @@ endfunc
func Test_invalid_arg() func Test_invalid_arg()
call assert_fails('syntax case asdf', 'E390:') call assert_fails('syntax case asdf', 'E390:')
call assert_fails('syntax conceal asdf', 'E390:') if has('conceal')
call assert_fails('syntax conceal asdf', 'E390:')
endif
call assert_fails('syntax spell asdf', 'E390:') call assert_fails('syntax spell asdf', 'E390:')
endfunc endfunc
@@ -313,13 +323,26 @@ endfunc
func Test_syn_clear() func Test_syn_clear()
syntax keyword Foo foo syntax keyword Foo foo
syntax keyword Tar tar syntax keyword Bar tar
call assert_match('Foo', execute('syntax')) call assert_match('Foo', execute('syntax'))
call assert_match('Tar', execute('syntax')) call assert_match('Bar', execute('syntax'))
syn clear Foo syn clear Foo
call assert_notmatch('Foo', execute('syntax')) call assert_notmatch('Foo', execute('syntax'))
call assert_match('Tar', execute('syntax')) call assert_match('Bar', execute('syntax'))
syn clear Foo Tar syn clear Foo Bar
call assert_notmatch('Foo', execute('syntax')) call assert_notmatch('Foo', execute('syntax'))
call assert_notmatch('Tar', execute('syntax')) call assert_notmatch('Bar', execute('syntax'))
hi clear Foo
hi clear Bar
endfunc
func Test_invalid_name()
syn clear
syn keyword Nop yes
call assert_fails("syntax keyword Wr\x17ong bar", 'E669:')
syntax keyword @Wrong bar
call assert_match('W18:', execute('1messages'))
syn clear
hi clear Nop
hi clear @Wrong
endfunc endfunc

View File

@@ -176,7 +176,17 @@ func Test_undojoin()
call assert_equal(['aaaa', 'bbbb', 'cccc'], getline(2, '$')) call assert_equal(['aaaa', 'bbbb', 'cccc'], getline(2, '$'))
call feedkeys("u", 'xt') call feedkeys("u", 'xt')
call assert_equal(['aaaa'], getline(2, '$')) call assert_equal(['aaaa'], getline(2, '$'))
close! bwipe!
endfunc
func Test_undojoin_redo()
new
call setline(1, ['first line', 'second line'])
call feedkeys("ixx\<Esc>", 'xt')
call feedkeys(":undojoin | redo\<CR>", 'xt')
call assert_equal('xxfirst line', getline(1))
call assert_equal('second line', getline(2))
bwipe!
endfunc endfunc
func Test_undo_write() func Test_undo_write()

View File

@@ -3136,11 +3136,8 @@ ex_undojoin(exarg_T *eap UNUSED)
if (get_undolevel() < 0) if (get_undolevel() < 0)
return; /* no entries, nothing to do */ return; /* no entries, nothing to do */
else else
{ /* Append next change to the last entry */
/* Go back to the last entry */ curbuf->b_u_synced = FALSE;
curbuf->b_u_curhead = curbuf->b_u_newhead;
curbuf->b_u_synced = FALSE; /* no entries, nothing to do */
}
} }
/* /*

View File

@@ -764,6 +764,18 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
206,
/**/
205,
/**/
204,
/**/
203,
/**/
202,
/**/
201,
/**/ /**/
200, 200,
/**/ /**/