Compare commits

...

9 Commits

Author SHA1 Message Date
Bram Moolenaar
3954e3c4b5 patch 8.0.0276: unnecessary #ifdefs
Problem:    Checking for FEAT_GUI_GNOME inside GTK 3 code is unnecessary.
Solution:   Remove the #ifdef. (Kazunobu Kuriyama)
2017-02-01 11:50:09 +01:00
Bram Moolenaar
e3caa11090 patch 8.0.0275: the screen may be updated at the wrong time
Problem:    When checking for CTRL-C typed the GUI may detect a screen resize
            and redraw the screen, causing trouble.
Solution:   Set updating_screen in ui_breakcheck().
2017-01-31 22:07:42 +01:00
Bram Moolenaar
070b33da93 patch 8.0.0274: possible recursive screen updating causes trouble
Problem:    When update_single_line() is called recursively, or another screen
            update happens while it is busy, errors may occur.
Solution:   Check and update updating_screen. (Christian Brabandt)
2017-01-31 21:53:39 +01:00
Bram Moolenaar
c4a249a736 patch 8.0.0273: dead code detected by Coverity
Problem:    Dead code detected by Coverity when not using gnome.
Solution:   Rearrange the #ifdefs to avoid dead code.
2017-01-30 22:56:48 +01:00
Bram Moolenaar
432c839ebd patch 8.0.0272: crash on exit is not detected when running tests
Problem:    Crash on exit is not detected when running tests.
Solution:   Remove the dash before the command. (Dominique Pelle, closes
            #1425)
2017-01-30 22:01:01 +01:00
Bram Moolenaar
a4c906a4a1 patch 8.0.0271: may get ml_get error when :tcldo deletes lines
Problem:    May get ml_get error when :tcldo deletes lines or switches to
            another buffer. (Nikolai Pavlov, closes #1421)
Solution:   Check the buffer and line every time.
2017-01-29 23:26:37 +01:00
Bram Moolenaar
c593fee0e5 patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Problem:    May get ml_get error when :rubydo deletes lines or switches to
            another buffer. (Nikolai Pavlov, issue #1421)
Solution:   Check the buffer and line every time.
2017-01-29 23:11:25 +01:00
Bram Moolenaar
85b5743d3e patch 8.0.0269: may get ml_get error when :perldo deletes lines
Problem:    May get ml_get error when :perldo deletes lines or switches to
            another buffer. (Nikolai Pavlov, issue #1421)
Solution:   Check the buffer and line every time.
2017-01-29 22:59:12 +01:00
Bram Moolenaar
d58f03b1c2 patch 8.0.0268: may get ml_get error when :luado deletes lines
Problem:    May get ml_get error when :luado deletes lines or switches to
            another buffer. (Nikolai Pavlov, issue #1421)
Solution:   Check the buffer and line every time.
2017-01-29 22:48:45 +01:00
15 changed files with 144 additions and 15 deletions

View File

@@ -2147,6 +2147,7 @@ test_arglist \
test_langmap \
test_largefile \
test_lispwords \
test_lua \
test_man \
test_mapping \
test_marks \
@@ -2197,6 +2198,7 @@ test_arglist \
test_tabpage \
test_tagcase \
test_tagjump \
test_tcl \
test_textobjects \
test_timers \
test_true_false \

View File

@@ -3171,9 +3171,9 @@ delete_event_cb(GtkWidget *widget UNUSED,
static int
get_item_dimensions(GtkWidget *widget, GtkOrientation orientation)
{
# ifdef FEAT_GUI_GNOME
GtkOrientation item_orientation = GTK_ORIENTATION_HORIZONTAL;
# ifdef FEAT_GUI_GNOME
if (using_gnome && widget != NULL)
{
GtkWidget *parent;
@@ -3192,7 +3192,10 @@ get_item_dimensions(GtkWidget *widget, GtkOrientation orientation)
item_orientation = bonobo_dock_item_get_orientation(dockitem);
}
}
# else
# define item_orientation GTK_ORIENTATION_HORIZONTAL
# endif
# if GTK_CHECK_VERSION(3,0,0)
if (widget != NULL
&& item_orientation == orientation
@@ -3209,16 +3212,16 @@ get_item_dimensions(GtkWidget *widget, GtkOrientation orientation)
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
if (orientation == GTK_ORIENTATION_HORIZONTAL)
return allocation.height;
else
return allocation.width;
return allocation.height;
# else
# ifdef FEAT_GUI_GNOME
if (orientation == GTK_ORIENTATION_HORIZONTAL)
return widget->allocation.height;
else
return widget->allocation.width;
# else
return widget->allocation.height;
# endif
# endif
}
return 0;

View File

@@ -1716,6 +1716,8 @@ ex_luado(exarg_T *eap)
const char *s = (const char *) eap->arg;
luaL_Buffer b;
size_t len;
buf_T *was_curbuf = curbuf;
if (lua_init() == FAIL) return;
if (u_save(eap->line1 - 1, eap->line2 + 1) == FAIL)
{
@@ -1739,6 +1741,10 @@ ex_luado(exarg_T *eap)
lua_replace(L, -2); /* function -> body */
for (l = eap->line1; l <= eap->line2; l++)
{
/* Check the line number, the command my have deleted lines. */
if (l > curbuf->b_ml.ml_line_count)
break;
lua_pushvalue(L, -1); /* function */
luaV_pushline(L, curbuf, l); /* current line as arg */
lua_pushinteger(L, l); /* current line number as arg */
@@ -1747,6 +1753,9 @@ ex_luado(exarg_T *eap)
luaV_emsg(L);
break;
}
/* Catch the command switching to another buffer. */
if (curbuf != was_curbuf)
break;
if (lua_isstring(L, -1)) /* update line? */
{
#ifdef HAVE_SANDBOX

View File

@@ -1286,6 +1286,7 @@ ex_perldo(exarg_T *eap)
SV *sv;
char *str;
linenr_T i;
buf_T *was_curbuf = curbuf;
if (bufempty())
return;
@@ -1321,11 +1322,14 @@ ex_perldo(exarg_T *eap)
SAVETMPS;
for (i = eap->line1; i <= eap->line2; i++)
{
/* Check the line number, the command my have deleted lines. */
if (i > curbuf->b_ml.ml_line_count)
break;
sv_setpv(GvSV(PL_defgv), (char *)ml_get(i));
PUSHMARK(sp);
perl_call_pv("VIM::perldo", G_SCALAR | G_EVAL);
str = SvPV(GvSV(PL_errgv), length);
if (length)
if (length || curbuf != was_curbuf)
break;
SPAGAIN;
if (SvTRUEx(POPs))

View File

@@ -783,6 +783,7 @@ void ex_rubydo(exarg_T *eap)
{
int state;
linenr_T i;
buf_T *was_curbuf = curbuf;
if (ensure_ruby_initialized())
{
@@ -792,6 +793,8 @@ void ex_rubydo(exarg_T *eap)
{
VALUE line;
if (i > curbuf->b_ml.ml_line_count)
break;
line = vim_str2rb_enc_str((char *)ml_get(i));
rb_lastline_set(line);
eval_enc_string_protect((char *) eap->arg, &state);
@@ -800,6 +803,8 @@ void ex_rubydo(exarg_T *eap)
error_print(state);
break;
}
if (was_curbuf != curbuf)
break;
line = rb_lastline_get();
if (!NIL_P(line))
{

View File

@@ -1958,6 +1958,7 @@ ex_tcldo(exarg_T *eap)
char var_line[VARNAME_SIZE];
linenr_T first_line = 0;
linenr_T last_line = 0;
buf_T *was_curbuf = curbuf;
rs = eap->line1;
re = eap->line2;
@@ -1979,6 +1980,8 @@ ex_tcldo(exarg_T *eap)
}
while (err == TCL_OK && rs <= re)
{
if ((linenr_T)rs > curbuf->b_ml.ml_line_count)
break;
line = (char *)ml_get_buf(curbuf, (linenr_T)rs, FALSE);
if (!line)
{
@@ -1994,7 +1997,7 @@ ex_tcldo(exarg_T *eap)
#if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 5) || TCL_MAJOR_VERSION > 8
|| Tcl_LimitExceeded(tclinfo.interp)
#endif
)
|| curbuf != was_curbuf)
break;
line = (char *)Tcl_GetVar(tclinfo.interp, var_line, 0);
if (line)

View File

@@ -824,8 +824,9 @@ update_single_line(win_T *wp, linenr_T lnum)
int j;
/* Don't do anything if the screen structures are (not yet) valid. */
if (!screen_valid(TRUE))
if (!screen_valid(TRUE) || updating_screen)
return;
updating_screen = TRUE;
if (lnum >= wp->w_topline && lnum < wp->w_botline
&& foldedCount(wp, lnum, &win_foldinfo) == 0)
@@ -865,13 +866,11 @@ update_single_line(win_T *wp, linenr_T lnum)
# endif
}
need_cursor_line_redraw = FALSE;
updating_screen = FALSE;
}
#endif
#if defined(FEAT_SIGNS) || defined(FEAT_GUI)
static void update_prepare(void);
static void update_finish(void);
/*
* Prepare for updating one or more windows.
* Caller must check for "updating_screen" already set to avoid recursiveness.

View File

@@ -164,6 +164,7 @@ NEW_TESTS = test_arglist.res \
test_job_fails.res \
test_json.res \
test_langmap.res \
test_lua.res \
test_man.res \
test_marks.res \
test_matchadd_conceal.res \
@@ -172,8 +173,8 @@ NEW_TESTS = test_arglist.res \
test_nested_function.res \
test_netbeans.res \
test_normal.res \
test_paste.res \
test_packadd.res \
test_paste.res \
test_perl.res \
test_profile.res \
test_python2.res \
@@ -192,6 +193,7 @@ NEW_TESTS = test_arglist.res \
test_substitute.res \
test_syntax.res \
test_system.res \
test_tcl.res \
test_textobjects.res \
test_undo.res \
test_usercommands.res \

View File

@@ -78,7 +78,7 @@ test1.out: test1.in
# 200 msec is sufficient, but only modern sleep supports a fraction of
# a second, fall back to a second if it fails.
@-/bin/sh -c "sleep .2 > /dev/null 2>&1 || sleep 1"
-$(RUN_VIM) $*.in
$(RUN_VIM) $*.in
# For flaky tests retry one time. No tests at the moment.
#@/bin/sh -c "if test -f test.out -a $* = test61; then \
@@ -108,7 +108,7 @@ bench_re_freeze.out: bench_re_freeze.vim
# 200 msec is sufficient, but only modern sleep supports a fraction of
# a second, fall back to a second if it fails.
@-/bin/sh -c "sleep .2 > /dev/null 2>&1 || sleep 1"
-$(RUN_VIM) $*.in
$(RUN_VIM) $*.in
@/bin/sh -c "if test -f benchmark.out; then cat benchmark.out; fi"
nolog:

22
src/testdir/test_lua.vim Normal file
View File

@@ -0,0 +1,22 @@
" Tests for Lua.
" TODO: move tests from test85.in here.
if !has('lua')
finish
endif
func Test_luado()
new
call setline(1, ['one', 'two', 'three'])
luado vim.command("%d_")
bwipe!
" Check switching to another buffer does not trigger ml_get error.
new
let wincount = winnr('$')
call setline(1, ['one', 'two', 'three'])
luado vim.command("new")
call assert_equal(wincount + 1, winnr('$'))
bwipe!
bwipe!
endfunc

View File

@@ -82,6 +82,21 @@ function Test_perldo()
1
call assert_false(search('\Cperl'))
bw!
" Check deleting lines does not trigger ml_get error.
new
call setline(1, ['one', 'two', 'three'])
perldo VIM::DoCommand("%d_")
bwipe!
" Check switching to another buffer does not trigger ml_get error.
new
let wincount = winnr('$')
call setline(1, ['one', 'two', 'three'])
perldo VIM::DoCommand("new")
call assert_equal(wincount + 1, winnr('$'))
bwipe!
bwipe!
endfunc
function Test_VIM_package()

View File

@@ -32,3 +32,20 @@ func Test_ruby_evaluate_dict()
redir END
call assert_equal(['{"a"=>"foo", "b"=>123}'], split(l:out, "\n"))
endfunc
func Test_rubydo()
" Check deleting lines does not trigger ml_get error.
new
call setline(1, ['one', 'two', 'three'])
rubydo Vim.command("%d_")
bwipe!
" Check switching to another buffer does not trigger ml_get error.
new
let wincount = winnr('$')
call setline(1, ['one', 'two', 'three'])
rubydo Vim.command("new")
call assert_equal(wincount + 1, winnr('$'))
bwipe!
bwipe!
endfunc

23
src/testdir/test_tcl.vim Normal file
View File

@@ -0,0 +1,23 @@
" Tests for the Tcl interface.
if !has('tcl')
finish
end
function Test_tcldo()
" Check deleting lines does not trigger ml_get error.
new
call setline(1, ['one', 'two', 'three'])
tcldo ::vim::command %d_
bwipe!
" Check switching to another buffer does not trigger ml_get error.
new
let wincount = winnr('$')
call setline(1, ['one', 'two', 'three'])
tcldo ::vim::command new
call assert_equal(wincount + 1, winnr('$'))
bwipe!
bwipe!
endfunc

View File

@@ -363,12 +363,19 @@ ui_breakcheck(void)
void
ui_breakcheck_force(int force)
{
int save_us = updating_screen;
/* We do not want gui_resize_shell() to redraw the screen here. */
++updating_screen;
#ifdef FEAT_GUI
if (gui.in_use)
gui_mch_update();
else
#endif
mch_breakcheck(force);
updating_screen = save_us;
}
/*****************************************************************************

View File

@@ -764,6 +764,24 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
276,
/**/
275,
/**/
274,
/**/
273,
/**/
272,
/**/
271,
/**/
270,
/**/
269,
/**/
268,
/**/
267,
/**/