Merge #9459 from janlazo/vim-8.1.0677

This commit is contained in:
Justin M. Keyes 2019-01-06 13:02:40 +01:00 committed by GitHub
commit ea7504cf8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 9 deletions

View File

@ -7103,7 +7103,7 @@ static void f_bufloaded(typval_T *argvars, typval_T *rettv, FunPtr fptr)
/* /*
* Get buffer by number or pattern. * Get buffer by number or pattern.
*/ */
static buf_T *get_buf_tv(typval_T *tv, int curtab_only) static buf_T *tv_get_buf(typval_T *tv, int curtab_only)
{ {
char_u *name = tv->vval.v_string; char_u *name = tv->vval.v_string;
int save_magic; int save_magic;
@ -7149,7 +7149,7 @@ static void f_bufname(typval_T *argvars, typval_T *rettv, FunPtr fptr)
return; return;
} }
emsg_off++; emsg_off++;
const buf_T *const buf = get_buf_tv(&argvars[0], false); const buf_T *const buf = tv_get_buf(&argvars[0], false);
emsg_off--; emsg_off--;
if (buf != NULL && buf->b_fname != NULL) { if (buf != NULL && buf->b_fname != NULL) {
rettv->vval.v_string = (char_u *)xstrdup((char *)buf->b_fname); rettv->vval.v_string = (char_u *)xstrdup((char *)buf->b_fname);
@ -7168,7 +7168,7 @@ static void f_bufnr(typval_T *argvars, typval_T *rettv, FunPtr fptr)
return; return;
} }
emsg_off++; emsg_off++;
const buf_T *buf = get_buf_tv(&argvars[0], false); const buf_T *buf = tv_get_buf(&argvars[0], false);
emsg_off--; emsg_off--;
// If the buffer isn't found and the second argument is not zero create a // If the buffer isn't found and the second argument is not zero create a
@ -7195,7 +7195,7 @@ static void buf_win_common(typval_T *argvars, typval_T *rettv, bool get_nr)
} }
emsg_off++; emsg_off++;
buf_T *buf = get_buf_tv(&argvars[0], true); buf_T *buf = tv_get_buf(&argvars[0], true);
if (buf == NULL) { // no need to search if buffer was not found if (buf == NULL) { // no need to search if buffer was not found
rettv->vval.v_number = -1; rettv->vval.v_number = -1;
goto end; goto end;
@ -9280,7 +9280,7 @@ static void f_getbufinfo(typval_T *argvars, typval_T *rettv, FunPtr fptr)
// Information about one buffer. Argument specifies the buffer // Information about one buffer. Argument specifies the buffer
if (tv_check_num(&argvars[0])) { // issue errmsg if type error if (tv_check_num(&argvars[0])) { // issue errmsg if type error
emsg_off++; emsg_off++;
argbuf = get_buf_tv(&argvars[0], false); argbuf = tv_get_buf(&argvars[0], false);
emsg_off--; emsg_off--;
if (argbuf == NULL) { if (argbuf == NULL) {
return; return;
@ -9376,7 +9376,7 @@ static void f_getbufline(typval_T *argvars, typval_T *rettv, FunPtr fptr)
if (tv_check_str_or_nr(&argvars[0])) { if (tv_check_str_or_nr(&argvars[0])) {
emsg_off++; emsg_off++;
buf = get_buf_tv(&argvars[0], false); buf = tv_get_buf(&argvars[0], false);
emsg_off--; emsg_off--;
} }
@ -9404,7 +9404,7 @@ static void f_getbufvar(typval_T *argvars, typval_T *rettv, FunPtr fptr)
const char *varname = tv_get_string_chk(&argvars[1]); const char *varname = tv_get_string_chk(&argvars[1]);
emsg_off++; emsg_off++;
buf_T *const buf = get_buf_tv(&argvars[0], false); buf_T *const buf = tv_get_buf(&argvars[0], false);
if (buf != NULL && varname != NULL) { if (buf != NULL && varname != NULL) {
// set curbuf to be our buf, temporarily // set curbuf to be our buf, temporarily
@ -14491,7 +14491,7 @@ static void f_setbufvar(typval_T *argvars, typval_T *rettv, FunPtr fptr)
return; return;
} }
const char *varname = tv_get_string_chk(&argvars[1]); const char *varname = tv_get_string_chk(&argvars[1]);
buf_T *const buf = get_buf_tv(&argvars[0], false); buf_T *const buf = tv_get_buf(&argvars[0], false);
typval_T *varp = &argvars[2]; typval_T *varp = &argvars[2];
if (buf != NULL && varname != NULL) { if (buf != NULL && varname != NULL) {

View File

@ -4920,7 +4920,7 @@ regmatch (
} }
} else { } else {
const char_u *const line = const char_u *const line =
reg_getline(behind_pos.rs_u.pos.lnum); reg_getline(rp->rs_un.regsave.rs_u.pos.lnum);
rp->rs_un.regsave.rs_u.pos.col -= rp->rs_un.regsave.rs_u.pos.col -=
utf_head_off(line, utf_head_off(line,

View File

@ -277,3 +277,44 @@ func Test_visual_mode_reset()
set belloff& set belloff&
endfunc endfunc
func Test_Visual_sentence_textobject()
new
call setline(1, ['First sentence. Second sentence. Third', 'sentence. Fouth sentence'])
" When start and end of visual area are identical, 'as' or 'is' select
" the whole sentence.
norm! 1gofdvasy
call assert_equal('Second sentence. ', @")
norm! 1gofdvisy
call assert_equal('Second sentence.', @")
" When start and end of visual area are not identical, 'as' or 'is'
" extend the sentence in direction of the end of the visual area.
norm! 1gofdvlasy
call assert_equal('d sentence. ', @")
norm! gvasy
call assert_equal("d sentence. Third\nsentence. ", @")
norm! 1gofdvlisy
call assert_equal('d sentence.', @")
norm! gvisy
call assert_equal('d sentence. ', @")
norm! gvisy
call assert_equal("d sentence. Third\nsentence.", @")
" Extend visual area in opposite direction.
norm! 1gofdvhasy
call assert_equal(' Second', @")
norm! gvasy
call assert_equal("First sentence. Second", @")
norm! 1gofdvhisy
call assert_equal('Second', @")
norm! gvisy
call assert_equal(' Second', @")
norm! gvisy
call assert_equal('First sentence. Second', @")
bwipe!
endfunc