Skip to content

Commit c11c152

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 67c67d1 + 1fb0d49 commit c11c152

14 files changed

Lines changed: 371 additions & 29 deletions

File tree

src/diff.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,23 @@ diff_buf_add(buf_T *buf)
138138
EMSGN(_("E96: Cannot diff more than %ld buffers"), DB_COUNT);
139139
}
140140

141+
/*
142+
* Remove all buffers to make diffs for.
143+
*/
144+
static void
145+
diff_buf_clear(void)
146+
{
147+
int i;
148+
149+
for (i = 0; i < DB_COUNT; ++i)
150+
if (curtab->tp_diffbuf[i] != NULL)
151+
{
152+
curtab->tp_diffbuf[i] = NULL;
153+
curtab->tp_diff_invalid = TRUE;
154+
diff_redraw(TRUE);
155+
}
156+
}
157+
141158
/*
142159
* Find buffer "buf" in the list of diff buffers for the current tab page.
143160
* Return its index or DB_COUNT if not found.
@@ -1257,6 +1274,10 @@ ex_diffoff(exarg_T *eap)
12571274
#endif
12581275
}
12591276

1277+
/* Also remove hidden buffers from the list. */
1278+
if (eap->forceit)
1279+
diff_buf_clear();
1280+
12601281
#ifdef FEAT_SCROLLBIND
12611282
/* Remove "hor" from from 'scrollopt' if there are no diff windows left. */
12621283
if (!diffwin && vim_strchr(p_sbo, 'h') != NULL)

src/ex_docmd.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4374,9 +4374,16 @@ skip_range(
43744374
{
43754375
unsigned delim;
43764376

4377-
while (vim_strchr((char_u *)" \t0123456789.$%'/?-+,;", *cmd) != NULL)
4377+
while (vim_strchr((char_u *)" \t0123456789.$%'/?-+,;\\", *cmd) != NULL)
43784378
{
4379-
if (*cmd == '\'')
4379+
if (*cmd == '\\')
4380+
{
4381+
if (cmd[1] == '?' || cmd[1] == '/' || cmd[1] == '&')
4382+
++cmd;
4383+
else
4384+
break;
4385+
}
4386+
else if (*cmd == '\'')
43804387
{
43814388
if (*++cmd == NUL && ctx != NULL)
43824389
*ctx = EXPAND_NOTHING;

src/gui.c

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,6 +1476,8 @@ gui_resize_shell(int pixel_width, int pixel_height)
14761476
}
14771477

14781478
again:
1479+
new_pixel_width = 0;
1480+
new_pixel_height = 0;
14791481
busy = TRUE;
14801482

14811483
/* Flush pending output before redrawing */
@@ -1485,8 +1487,8 @@ gui_resize_shell(int pixel_width, int pixel_height)
14851487
gui.num_rows = (pixel_height - gui_get_base_height()) / gui.char_height;
14861488

14871489
gui_position_components(pixel_width);
1488-
14891490
gui_reset_scroll_region();
1491+
14901492
/*
14911493
* At the "more" and ":confirm" prompt there is no redraw, put the cursor
14921494
* at the last line here (why does it have to be one row too low?).
@@ -1508,17 +1510,22 @@ gui_resize_shell(int pixel_width, int pixel_height)
15081510

15091511
busy = FALSE;
15101512

1511-
/*
1512-
* We could have been called again while redrawing the screen.
1513-
* Need to do it all again with the latest size then.
1514-
*/
1513+
/* We may have been called again while redrawing the screen.
1514+
* Need to do it all again with the latest size then. But only if the size
1515+
* actually changed. */
15151516
if (new_pixel_height)
15161517
{
1517-
pixel_width = new_pixel_width;
1518-
pixel_height = new_pixel_height;
1519-
new_pixel_width = 0;
1520-
new_pixel_height = 0;
1521-
goto again;
1518+
if (pixel_width == new_pixel_width && pixel_height == new_pixel_height)
1519+
{
1520+
new_pixel_width = 0;
1521+
new_pixel_height = 0;
1522+
}
1523+
else
1524+
{
1525+
pixel_width = new_pixel_width;
1526+
pixel_height = new_pixel_height;
1527+
goto again;
1528+
}
15221529
}
15231530
}
15241531

@@ -1528,18 +1535,10 @@ gui_resize_shell(int pixel_width, int pixel_height)
15281535
void
15291536
gui_may_resize_shell(void)
15301537
{
1531-
int h, w;
1532-
15331538
if (new_pixel_height)
1534-
{
15351539
/* careful: gui_resize_shell() may postpone the resize again if we
15361540
* were called indirectly by it */
1537-
w = new_pixel_width;
1538-
h = new_pixel_height;
1539-
new_pixel_width = 0;
1540-
new_pixel_height = 0;
1541-
gui_resize_shell(w, h);
1542-
}
1541+
gui_resize_shell(new_pixel_width, new_pixel_height);
15431542
}
15441543

15451544
int

src/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,6 +1187,10 @@ main_loop(
11871187
skip_redraw = FALSE;
11881188
else if (do_redraw || stuff_empty())
11891189
{
1190+
# ifdef FEAT_GUI
1191+
/* If ui_breakcheck() was used a resize may have been postponed. */
1192+
gui_may_resize_shell();
1193+
# endif
11901194
#if defined(FEAT_AUTOCMD) || defined(FEAT_CONCEAL)
11911195
/* Trigger CursorMoved if the cursor moved. */
11921196
if (!finish_op && (

src/normal.c

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9084,6 +9084,34 @@ nv_edit(cmdarg_T *cap)
90849084
/* drop the pasted text */
90859085
bracketed_paste(PASTE_INSERT, TRUE, NULL);
90869086
}
9087+
else if (cap->cmdchar == K_PS && VIsual_active)
9088+
{
9089+
pos_T old_pos = curwin->w_cursor;
9090+
pos_T old_visual = VIsual;
9091+
9092+
/* In Visual mode the selected text is deleted. */
9093+
if (VIsual_mode == 'V' || curwin->w_cursor.lnum != VIsual.lnum)
9094+
{
9095+
shift_delete_registers();
9096+
cap->oap->regname = '1';
9097+
}
9098+
else
9099+
cap->oap->regname = '-';
9100+
cap->cmdchar = 'd';
9101+
cap->nchar = NUL;
9102+
nv_operator(cap);
9103+
do_pending_operator(cap, 0, FALSE);
9104+
cap->cmdchar = K_PS;
9105+
9106+
/* When the last char in the line was deleted then append. Detect this
9107+
* by checking if the cursor moved to before the Visual area. */
9108+
if (*ml_get_cursor() != NUL && lt(curwin->w_cursor, old_pos)
9109+
&& lt(curwin->w_cursor, old_visual))
9110+
inc_cursor();
9111+
9112+
/* Insert to replace the deleted text with the pasted text. */
9113+
invoke_edit(cap, FALSE, cap->cmdchar, FALSE);
9114+
}
90879115
else if (!checkclearopq(cap->oap))
90889116
{
90899117
switch (cap->cmdchar)
@@ -9113,8 +9141,9 @@ nv_edit(cmdarg_T *cap)
91139141
beginline(BL_WHITE|BL_FIX);
91149142
break;
91159143

9116-
case K_PS: /* Bracketed paste works like "a"ppend, unless the
9117-
cursor is in the first column, then it inserts. */
9144+
case K_PS:
9145+
/* Bracketed paste works like "a"ppend, unless the cursor is in
9146+
* the first column, then it inserts. */
91189147
if (curwin->w_cursor.col == 0)
91199148
break;
91209149
/*FALLTHROUGH*/

src/ops.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,6 +1627,22 @@ adjust_clip_reg(int *rp)
16271627
}
16281628
#endif
16291629

1630+
/*
1631+
* Shift the delete registers: "9 is cleared, "8 becomes "9, etc.
1632+
*/
1633+
void
1634+
shift_delete_registers()
1635+
{
1636+
int n;
1637+
1638+
y_current = &y_regs[9];
1639+
free_yank_all(); /* free register nine */
1640+
for (n = 9; n > 1; --n)
1641+
y_regs[n] = y_regs[n - 1];
1642+
y_previous = y_current = &y_regs[1];
1643+
y_regs[1].y_array = NULL; /* set register one to empty */
1644+
}
1645+
16301646
/*
16311647
* Handle a delete operation.
16321648
*
@@ -1739,12 +1755,7 @@ op_delete(oparg_T *oap)
17391755
if (orig_regname != 0 || oap->motion_type == MLINE
17401756
|| oap->line_count > 1 || oap->use_reg_one)
17411757
{
1742-
y_current = &y_regs[9];
1743-
free_yank_all(); /* free register nine */
1744-
for (n = 9; n > 1; --n)
1745-
y_regs[n] = y_regs[n - 1];
1746-
y_previous = y_current = &y_regs[1];
1747-
y_regs[1].y_array = NULL; /* set register one to empty */
1758+
shift_delete_registers();
17481759
if (op_yank(oap, TRUE, FALSE) == OK)
17491760
did_yank = TRUE;
17501761
}

src/option.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9380,7 +9380,35 @@ get_option_value(
93809380

93819381
opt_idx = findoption(name);
93829382
if (opt_idx < 0) /* unknown option */
9383+
{
9384+
int key;
9385+
9386+
if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_'
9387+
&& (key = find_key_option(name)) != 0)
9388+
{
9389+
char_u key_name[2];
9390+
char_u *p;
9391+
9392+
if (key < 0)
9393+
{
9394+
key_name[0] = KEY2TERMCAP0(key);
9395+
key_name[1] = KEY2TERMCAP1(key);
9396+
}
9397+
else
9398+
{
9399+
key_name[0] = KS_KEY;
9400+
key_name[1] = (key & 0xff);
9401+
}
9402+
p = find_termcode(key_name);
9403+
if (p != NULL)
9404+
{
9405+
if (stringval != NULL)
9406+
*stringval = vim_strsave(p);
9407+
return 0;
9408+
}
9409+
}
93839410
return -3;
9411+
}
93849412

93859413
varp = get_varp_scope(&(options[opt_idx]), opt_flags);
93869414

@@ -9638,7 +9666,33 @@ set_option_value(
96389666

96399667
opt_idx = findoption(name);
96409668
if (opt_idx < 0)
9669+
{
9670+
int key;
9671+
9672+
if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_'
9673+
&& (key = find_key_option(name)) != 0)
9674+
{
9675+
char_u key_name[2];
9676+
9677+
if (key < 0)
9678+
{
9679+
key_name[0] = KEY2TERMCAP0(key);
9680+
key_name[1] = KEY2TERMCAP1(key);
9681+
}
9682+
else
9683+
{
9684+
key_name[0] = KS_KEY;
9685+
key_name[1] = (key & 0xff);
9686+
}
9687+
add_termcode(key_name, string, FALSE);
9688+
if (full_screen)
9689+
ttest(FALSE);
9690+
redraw_all_later(CLEAR);
9691+
return NULL;
9692+
}
9693+
96419694
EMSG2(_("E355: Unknown option: %s"), name);
9695+
}
96429696
else
96439697
{
96449698
flags = options[opt_idx].flags;

src/proto/ops.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ int insert_reg(int regname, int literally);
2323
int get_spec_reg(int regname, char_u **argp, int *allocated, int errmsg);
2424
int cmdline_paste_reg(int regname, int literally, int remcr);
2525
void adjust_clip_reg(int *rp);
26+
void shift_delete_registers(void);
2627
int op_delete(oparg_T *oap);
2728
int op_replace(oparg_T *oap, int c);
2829
void op_tilde(oparg_T *oap);

src/testdir/test_assign.vim

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,25 @@ func Test_no_type_checking()
77
let v = 3.4
88
let v = 'hello'
99
endfunc
10+
11+
func Test_let_termcap()
12+
" Terminal code
13+
let old_t_te = &t_te
14+
let &t_te = "\<Esc>[yes;"
15+
call assert_match('t_te.*^[[yes;', execute("set termcap"))
16+
let &t_te = old_t_te
17+
18+
if !has('gui_running')
19+
" Key code
20+
let old_t_k1 = &t_k1
21+
let &t_k1 = "that"
22+
call assert_match('t_k1.*that', execute("set termcap"))
23+
let &t_k1 = old_t_k1
24+
endif
25+
26+
call assert_fails('let x = &t_xx', 'E15')
27+
let &t_xx = "yes"
28+
call assert_equal("yes", &t_xx)
29+
let &t_xx = ""
30+
call assert_fails('let x = &t_xx', 'E15')
31+
endfunc

src/testdir/test_cmdline.vim

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,3 +306,28 @@ func Test_cmdline_complete_wildoptions()
306306
call assert_equal(a, b)
307307
bw!
308308
endfunc
309+
310+
" using a leading backslash here
311+
set cpo+=C
312+
313+
func Test_cmdline_search_range()
314+
new
315+
call setline(1, ['a', 'b', 'c', 'd'])
316+
/d
317+
1,\/s/b/B/
318+
call assert_equal('B', getline(2))
319+
320+
/a
321+
$
322+
\?,4s/c/C/
323+
call assert_equal('C', getline(3))
324+
325+
call setline(1, ['a', 'b', 'c', 'd'])
326+
%s/c/c/
327+
1,\&s/b/B/
328+
call assert_equal('B', getline(2))
329+
330+
bwipe!
331+
endfunc
332+
333+
set cpo&

0 commit comments

Comments
 (0)