Compare commits

..

9 Commits

Author SHA1 Message Date
Bram Moolenaar
d92cc130fb patch 8.2.2012: Vim9: confusing error message when using bool wrongly
Problem:    Vim9: confusing error message when using bool wrongly.
Solution:   Mention "Bool" instead of "Special". (closes #7323)
2020-11-18 17:17:15 +01:00
Bram Moolenaar
9950280d37 patch 8.2.2011: "syn sync" reports a very large number
Problem:    "syn sync" reports a very large number.
Solution:   Use "at the first line".
2020-11-18 16:53:23 +01:00
Bram Moolenaar
8e02faf4e9 patch 8.2.2010: Vim9: compiling fails for unreachable return statement
Problem:    Vim9: compiling fails for unreachable return statement.
Solution:   Fix it. (closes #7319)
2020-11-18 16:35:02 +01:00
Bram Moolenaar
382319211a patch 8.2.2009: MS-Windows: setting $LANG in gvimext only causes problems
Problem:    MS-Windows: setting $LANG in gvimext only causes problems.
Solution:   Do not set $LANG. (Ken Takata, closes #7325)
2020-11-18 15:30:09 +01:00
Bram Moolenaar
032f40afb8 patch 8.2.2008: MS-Windows GUI: handling channel messages lags
Problem:    MS-Windows GUI: handling channel messages lags.
Solution:   Reduce the wait time from 100 to 10 msec. (closes #7097)
2020-11-18 15:21:50 +01:00
Bram Moolenaar
17ab28daa0 patch 8.2.2007: test for insert mode in popup is not reliable
Problem:    Test for insert mode in popup is not reliable.
Solution:   Wait for the popup to disappear. (Ozaki Kiichi, closes #7321)
2020-11-18 12:24:01 +01:00
Bram Moolenaar
88774a30c0 patch 8.2.2006: .pbtxt files are not recognized
Problem:    .pbtxt files are not recognized.
Solution:   Recognize .pbtxt as protobuf text buffers. (closes #7326)
2020-11-18 12:12:39 +01:00
Bram Moolenaar
c77534c303 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Problem:    Redoing a mapping with <Cmd> doesn't work properly.
Solution:   Fill the redo buffer.  Use "<SNR>" instead of a key code.
            (closes #7282)
2020-11-18 11:34:37 +01:00
Bram Moolenaar
b3a01946b3 patch 8.2.2004: compiler warning for uninitialized variable
Problem:    Compiler warning for uninitialized variable.
Solution:   Initialize "ufunc". (John Marriott)
2020-11-17 19:56:09 +01:00
16 changed files with 142 additions and 110 deletions

View File

@@ -1305,6 +1305,7 @@ au BufNewFile,BufRead *.pml setf promela
" Google protocol buffers
au BufNewFile,BufRead *.proto setf proto
au BufNewFile,BufRead *.pbtxt setf pbtxt
" Protocols
au BufNewFile,BufRead */etc/protocols setf protocols

View File

@@ -161,7 +161,6 @@ static char *null_libintl_bindtextdomain(const char *, const char *);
static int dyn_libintl_init(char *dir);
static void dyn_libintl_end(void);
static wchar_t *oldenv = NULL;
static HINSTANCE hLibintlDLL = 0;
static char *(*dyn_libintl_gettext)(const char *) = null_libintl_gettext;
static char *(*dyn_libintl_textdomain)(const char *) = null_libintl_textdomain;
@@ -205,17 +204,17 @@ dyn_libintl_init(char *dir)
if (buf != NULL && buf2 != NULL)
{
GetEnvironmentVariableW(L"PATH", buf, len);
#ifdef _WIN64
# ifdef _WIN64
_snwprintf(buf2, len2, L"%S\\GvimExt64;%s", dir, buf);
#else
# else
_snwprintf(buf2, len2, L"%S\\GvimExt32;%s", dir, buf);
#endif
# endif
SetEnvironmentVariableW(L"PATH", buf2);
hLibintlDLL = LoadLibrary(GETTEXT_DLL);
#ifdef GETTEXT_DLL_ALT
# ifdef GETTEXT_DLL_ALT
if (!hLibintlDLL)
hLibintlDLL = LoadLibrary(GETTEXT_DLL_ALT);
#endif
# endif
SetEnvironmentVariableW(L"PATH", buf);
}
free(buf);
@@ -273,56 +272,7 @@ null_libintl_textdomain(const char* /* domainname */)
dyn_gettext_load(void)
{
char szBuff[BUFSIZE];
char szLang[BUFSIZE];
DWORD len;
HKEY keyhandle;
int gotlang = 0;
strcpy(szLang, "LANG=");
// First try getting the language from the registry, this can be
// used to overrule the system language.
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Vim\\Gvim", 0,
KEY_READ, &keyhandle) == ERROR_SUCCESS)
{
len = BUFSIZE;
if (RegQueryValueEx(keyhandle, "lang", 0, NULL, (BYTE*)szBuff, &len)
== ERROR_SUCCESS)
{
szBuff[len] = 0;
strcat(szLang, szBuff);
gotlang = 1;
}
RegCloseKey(keyhandle);
}
if (!gotlang && getenv("LANG") == NULL)
{
// Get the language from the system.
// Could use LOCALE_SISO639LANGNAME, but it's not in Win95.
// LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use
// only the first two.
len = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME,
(LPTSTR)szBuff, BUFSIZE);
if (len >= 2 && _strnicmp(szBuff, "en", 2) != 0)
{
// There are a few exceptions (probably more)
if (_strnicmp(szBuff, "cht", 3) == 0
|| _strnicmp(szBuff, "zht", 3) == 0)
strcpy(szBuff, "zh_TW");
else if (_strnicmp(szBuff, "chs", 3) == 0
|| _strnicmp(szBuff, "zhc", 3) == 0)
strcpy(szBuff, "zh_CN");
else if (_strnicmp(szBuff, "jp", 2) == 0)
strcpy(szBuff, "ja");
else
szBuff[2] = 0; // truncate to two-letter code
strcat(szLang, szBuff);
gotlang = 1;
}
}
if (gotlang)
putenv(szLang);
// Try to locate the runtime files. The path is used to find libintl.dll
// and the vim.mo files.
@@ -378,10 +328,8 @@ DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /* lpReserved */)
inc_cRefThisDLL()
{
#ifdef FEAT_GETTEXT
if (g_cRefThisDll == 0) {
if (g_cRefThisDll == 0)
dyn_gettext_load();
oldenv = GetEnvironmentStringsW();
}
#endif
InterlockedIncrement((LPLONG)&g_cRefThisDll);
}
@@ -390,13 +338,8 @@ inc_cRefThisDLL()
dec_cRefThisDLL()
{
#ifdef FEAT_GETTEXT
if (InterlockedDecrement((LPLONG)&g_cRefThisDll) == 0) {
if (InterlockedDecrement((LPLONG)&g_cRefThisDll) == 0)
dyn_gettext_free();
if (oldenv != NULL) {
FreeEnvironmentStringsW(oldenv);
oldenv = NULL;
}
}
#else
InterlockedDecrement((LPLONG)&g_cRefThisDll);
#endif
@@ -967,8 +910,8 @@ STDMETHODIMP CShellExt::InvokeGvim(HWND hParent,
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
oldenv == NULL ? 0 : CREATE_UNICODE_ENVIRONMENT,
oldenv, // Use unmodified environment block.
0, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi) // Pointer to PROCESS_INFORMATION structure.
@@ -1057,8 +1000,8 @@ STDMETHODIMP CShellExt::InvokeSingleGvim(HWND hParent,
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
oldenv == NULL ? 0 : CREATE_UNICODE_ENVIRONMENT,
oldenv, // Use unmodified environment block.
0, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi) // Pointer to PROCESS_INFORMATION structure.

View File

@@ -301,3 +301,5 @@ EXTERN char e_cmd_mapping_must_end_with_cr_before_second_cmd[]
INIT(=N_("E1136: <Cmd> mapping must end with <CR> before second <Cmd>"));
EXTERN char e_cmd_maping_must_not_include_str_key[]
INIT(= N_("E1137: <Cmd> mapping must not include %s key"));
EXTERN char e_using_bool_as_number[]
INIT(= N_("E1138: Using a Bool as a Number"));

View File

@@ -3691,11 +3691,7 @@ getcmdkeycmd(
else if (IS_SPECIAL(c1))
{
if (c1 == K_SNR)
{
ga_append(&line_ga, (char)K_SPECIAL);
ga_append(&line_ga, (char)KS_EXTRA);
ga_append(&line_ga, (char)KE_SNR);
}
ga_concat(&line_ga, (char_u *)"<SNR>");
else
{
semsg(e_cmd_maping_must_not_include_str_key,

View File

@@ -2134,7 +2134,10 @@ gui_mch_wait_for_chars(int wtime)
break;
}
else if (input_available()
|| MsgWaitForMultipleObjects(0, NULL, FALSE, 100,
// TODO: The 10 msec is a compromise between laggy response
// and consuming more CPU time. Better would be to handle
// channel messages when they arrive.
|| MsgWaitForMultipleObjects(0, NULL, FALSE, 10,
QS_ALLINPUT) != WAIT_TIMEOUT)
break;
}
@@ -8458,7 +8461,7 @@ make_tooltip(BalloonEval *beval, char *text, POINT pt)
TOOLINFOW *pti;
int ToolInfoSize;
if (multiline_balloon_available() == TRUE)
if (multiline_balloon_available())
ToolInfoSize = sizeof(TOOLINFOW_NEW);
else
ToolInfoSize = sizeof(TOOLINFOW);
@@ -8481,7 +8484,7 @@ make_tooltip(BalloonEval *beval, char *text, POINT pt)
pti->hinst = 0; // Don't use string resources
pti->uId = ID_BEVAL_TOOLTIP;
if (multiline_balloon_available() == TRUE)
if (multiline_balloon_available())
{
RECT rect;
TOOLINFOW_NEW *ptin = (TOOLINFOW_NEW *)pti;

View File

@@ -3465,8 +3465,9 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
if ((redo_yank || oap->op_type != OP_YANK)
&& ((!VIsual_active || oap->motion_force)
// Also redo Operator-pending Visual mode mappings
|| (VIsual_active && cap->cmdchar == ':'
&& oap->op_type != OP_COLON))
|| (VIsual_active
&& (cap->cmdchar == ':' || cap->cmdchar == K_COMMAND)
&& oap->op_type != OP_COLON))
&& cap->cmdchar != 'D'
#ifdef FEAT_FOLDING
&& oap->op_type != OP_FOLD
@@ -3688,7 +3689,7 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
get_op_char(oap->op_type),
get_extra_op_char(oap->op_type),
oap->motion_force, cap->cmdchar, cap->nchar);
else if (cap->cmdchar != ':')
else if (cap->cmdchar != ':' && cap->cmdchar != K_COMMAND)
{
int nchar = oap->op_type == OP_REPLACE ? cap->nchar : NUL;

View File

@@ -3869,9 +3869,14 @@ syn_cmd_list(
msg_puts(_("no syncing"));
else
{
msg_puts(_("syncing starts "));
msg_outnum(curwin->w_s->b_syn_sync_minlines);
msg_puts(_(" lines before top line"));
if (curwin->w_s->b_syn_sync_minlines == MAXLNUM)
msg_puts(_("syncing starts at the first line"));
else
{
msg_puts(_("syncing starts "));
msg_outnum(curwin->w_s->b_syn_sync_minlines);
msg_puts(_(" lines before top line"));
}
syn_match_msg();
}
return;
@@ -3935,19 +3940,24 @@ syn_lines_msg(void)
|| curwin->w_s->b_syn_sync_minlines > 0)
{
msg_puts("; ");
if (curwin->w_s->b_syn_sync_minlines > 0)
if (curwin->w_s->b_syn_sync_minlines == MAXLNUM)
msg_puts(_("from the first line"));
else
{
msg_puts(_("minimal "));
msg_outnum(curwin->w_s->b_syn_sync_minlines);
if (curwin->w_s->b_syn_sync_maxlines)
msg_puts(", ");
if (curwin->w_s->b_syn_sync_minlines > 0)
{
msg_puts(_("minimal "));
msg_outnum(curwin->w_s->b_syn_sync_minlines);
if (curwin->w_s->b_syn_sync_maxlines)
msg_puts(", ");
}
if (curwin->w_s->b_syn_sync_maxlines > 0)
{
msg_puts(_("maximal "));
msg_outnum(curwin->w_s->b_syn_sync_maxlines);
}
msg_puts(_(" lines before top line"));
}
if (curwin->w_s->b_syn_sync_maxlines > 0)
{
msg_puts(_("maximal "));
msg_outnum(curwin->w_s->b_syn_sync_maxlines);
}
msg_puts(_(" lines before top line"));
}
}

View File

@@ -345,6 +345,7 @@ let s:filename_checks = {
\ 'papp': ['file.papp', 'file.pxml', 'file.pxsl'],
\ 'pascal': ['file.pas', 'file.pp', 'file.dpr', 'file.lpr'],
\ 'passwd': ['any/etc/passwd', 'any/etc/passwd-', 'any/etc/passwd.edit', 'any/etc/shadow', 'any/etc/shadow-', 'any/etc/shadow.edit', 'any/var/backups/passwd.bak', 'any/var/backups/shadow.bak', '/etc/passwd', '/etc/passwd-', '/etc/passwd.edit', '/etc/shadow', '/etc/shadow-', '/etc/shadow.edit', '/var/backups/passwd.bak', '/var/backups/shadow.bak'],
\ 'pbtxt': ['file.pbtxt'],
\ 'pccts': ['file.g'],
\ 'pdf': ['file.pdf'],
\ 'perl': ['file.plx', 'file.al', 'file.psgi', 'gitolite.rc', '.gitolite.rc', 'example.gitolite.rc'],

View File

@@ -1324,4 +1324,40 @@ func Test_map_cmdkey_cmdline_mode()
%bw!
endfunc
func Test_map_cmdkey_redo()
func SelectDash()
call search('^---\n\zs', 'bcW')
norm! V
call search('\n\ze---$', 'W')
endfunc
let text =<< trim END
---
aaa
---
bbb
bbb
---
ccc
ccc
ccc
---
END
new Xcmdtext
call setline(1, text)
onoremap <silent> i- <Cmd>call SelectDash()<CR>
call feedkeys('2Gdi-', 'xt')
call assert_equal(['---', '---'], getline(1, 2))
call feedkeys('j.', 'xt')
call assert_equal(['---', '---', '---'], getline(1, 3))
call feedkeys('j.', 'xt')
call assert_equal(['---', '---', '---', '---'], getline(1, 4))
bwipe!
call delete('Xcmdtext')
delfunc SelectDash
ounmap i-
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -316,6 +316,8 @@ func Test_syntax_arg_skipped()
syn sync ccomment
endif
call assert_notmatch('on C-style comments', execute('syntax sync'))
syn sync fromstart
call assert_match('syncing starts at the first line', execute('syntax sync'))
syn clear
endfunc
@@ -735,6 +737,7 @@ func Test_syntax_foldlevel()
redir END
call assert_equal("\nsyntax foldlevel start", @c)
syn sync fromstart
call assert_match('from the first line$', execute('syn sync'))
let a = map(range(3,9), 'foldclosed(v:val)')
call assert_equal([3,3,3,3,3,3,3], a) " attached cascade folds together
let a = map(range(10,15), 'foldclosed(v:val)')

View File

@@ -1266,7 +1266,7 @@ func Test_terminal_popup_insert_cmd()
call assert_equal('n', mode())
call feedkeys("\<C-D>", 'xt')
sleep 50m
call WaitFor({-> popup_list() == []})
delfunc StartTermInPopup
iunmap <F3>
endfunc

View File

@@ -749,6 +749,9 @@ def Test_disassemble_const_expr()
enddef
def ReturnInIf(): string
if 1 < 0
return "maybe"
endif
if g:cond
return "yes"
else
@@ -759,6 +762,9 @@ enddef
def Test_disassemble_return_in_if()
var instr = execute('disassemble ReturnInIf')
assert_match('ReturnInIf\_s*' ..
'if 1 < 0\_s*' ..
' return "maybe"\_s*' ..
'endif\_s*' ..
'if g:cond\_s*' ..
'0 LOADG g:cond\_s*' ..
'1 COND2BOOL\_s*' ..

View File

@@ -1292,6 +1292,13 @@ func Test_expr5_fails()
call CheckDefFailure(["var x = 'a' .. 0z32"], 'E1105:', 1)
call CheckDefFailure(["var x = 'a' .. function('len')"], 'E1105:', 1)
call CheckDefFailure(["var x = 'a' .. function('len', ['a'])"], 'E1105:', 1)
call CheckScriptFailure(['vim9script', 'var x = 1 + v:none'], 'E611:', 2)
call CheckScriptFailure(['vim9script', 'var x = 1 + v:null'], 'E611:', 2)
call CheckScriptFailure(['vim9script', 'var x = 1 + v:true'], 'E1138:', 2)
call CheckScriptFailure(['vim9script', 'var x = 1 + v:false'], 'E1138:', 2)
call CheckScriptFailure(['vim9script', 'var x = 1 + true'], 'E1138:', 2)
call CheckScriptFailure(['vim9script', 'var x = 1 + false'], 'E1138:', 2)
endfunc
func Test_expr5_fails_channel()

View File

@@ -213,7 +213,10 @@ tv_get_bool_or_number_chk(typval_T *varp, int *denote, int want_bool)
case VAR_SPECIAL:
if (!want_bool && in_vim9script())
{
emsg(_("E611: Using a Special as a Number"));
if (varp->v_type == VAR_BOOL)
emsg(_(e_using_bool_as_number));
else
emsg(_("E611: Using a Special as a Number"));
break;
}
return varp->vval.v_number == VVAL_TRUE ? 1 : 0;

View File

@@ -750,6 +750,24 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
2012,
/**/
2011,
/**/
2010,
/**/
2009,
/**/
2008,
/**/
2007,
/**/
2006,
/**/
2005,
/**/
2004,
/**/
2003,
/**/

View File

@@ -2626,7 +2626,7 @@ compile_call(
char_u fname_buf[FLEN_FIXED + 1];
char_u *tofree = NULL;
int error = FCERR_NONE;
ufunc_T *ufunc;
ufunc_T *ufunc = NULL;
int res = FAIL;
int is_autoload;
@@ -4694,21 +4694,24 @@ compile_return(char_u *arg, int set_return_type, cctx_T *cctx)
if (compile_expr0(&p, cctx) == FAIL)
return NULL;
stack_type = ((type_T **)stack->ga_data)[stack->ga_len - 1];
if (set_return_type)
cctx->ctx_ufunc->uf_ret_type = stack_type;
else
if (cctx->ctx_skip != SKIP_YES)
{
if (cctx->ctx_ufunc->uf_ret_type->tt_type == VAR_VOID
&& stack_type->tt_type != VAR_VOID
&& stack_type->tt_type != VAR_UNKNOWN)
stack_type = ((type_T **)stack->ga_data)[stack->ga_len - 1];
if (set_return_type)
cctx->ctx_ufunc->uf_ret_type = stack_type;
else
{
emsg(_(e_returning_value_in_function_without_return_type));
return NULL;
}
if (need_type(stack_type, cctx->ctx_ufunc->uf_ret_type, -1,
if (cctx->ctx_ufunc->uf_ret_type->tt_type == VAR_VOID
&& stack_type->tt_type != VAR_VOID
&& stack_type->tt_type != VAR_UNKNOWN)
{
emsg(_(e_returning_value_in_function_without_return_type));
return NULL;
}
if (need_type(stack_type, cctx->ctx_ufunc->uf_ret_type, -1,
cctx, FALSE, FALSE) == FAIL)
return NULL;
return NULL;
}
}
}
else
@@ -4725,8 +4728,7 @@ compile_return(char_u *arg, int set_return_type, cctx_T *cctx)
// No argument, return zero.
generate_PUSHNR(cctx, 0);
}
if (generate_instr(cctx, ISN_RETURN) == NULL)
if (cctx->ctx_skip != SKIP_YES && generate_instr(cctx, ISN_RETURN) == NULL)
return NULL;
// "return val | endif" is possible