mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-02 11:19:22 +02:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2cefa1e3ce | |||
| 72f2e94815 | |||
| 14363db5ce | |||
| 9a32768aa6 | |||
| 67435d9983 | |||
| fafcf0dd59 | |||
| ff930cad8a | |||
| 87ffb5c1a3 |
@@ -492,6 +492,18 @@ CmdUndefined When a user command is used but it isn't
|
||||
command is defined. An alternative is to
|
||||
always define the user command and have it
|
||||
invoke an autoloaded function. See |autoload|.
|
||||
*CmdlineEnter*
|
||||
CmdlineEnter After moving the cursor to the command line,
|
||||
where the user can type a command or search
|
||||
string.
|
||||
<afile> is set to a single character,
|
||||
indicating the type of command-line.
|
||||
|cmdwin-char|
|
||||
*CmdlineLeave*
|
||||
CmdlineLeave Before leaving the command line.
|
||||
<afile> is set to a single character,
|
||||
indicating the type of command-line.
|
||||
|cmdwin-char|
|
||||
*CmdwinEnter*
|
||||
CmdwinEnter After entering the command-line window.
|
||||
Useful for setting options specifically for
|
||||
|
||||
@@ -1255,7 +1255,7 @@
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>139</string>
|
||||
<string>140</string>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
|
||||
+3
-3
@@ -28,10 +28,10 @@ endif
|
||||
" MacVim uses Homebrew python3 if installed, next try to use python.org binary
|
||||
if exists("&pythonthreedll") && exists("&pythonthreehome") &&
|
||||
\ !filereadable(&pythonthreedll)
|
||||
if filereadable("/Library/Frameworks/Python.framework/Versions/3.5/Python")
|
||||
if filereadable("/Library/Frameworks/Python.framework/Versions/3.6/Python")
|
||||
" https://www.python.org/downloads/mac-osx/
|
||||
set pythonthreedll=/Library/Frameworks/Python.framework/Versions/3.5/Python
|
||||
set pythonthreehome=/Library/Frameworks/Python.framework/Versions/3.5
|
||||
set pythonthreedll=/Library/Frameworks/Python.framework/Versions/3.6/Python
|
||||
set pythonthreehome=/Library/Frameworks/Python.framework/Versions/3.6
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
+30
-27
@@ -1714,7 +1714,7 @@ script_do_profile(scriptitem_T *si)
|
||||
}
|
||||
|
||||
/*
|
||||
* save time when starting to invoke another script or function.
|
||||
* Save time when starting to invoke another script or function.
|
||||
*/
|
||||
void
|
||||
script_prof_save(
|
||||
@@ -1805,12 +1805,14 @@ script_dump_profile(FILE *fd)
|
||||
fprintf(fd, "Cannot open file!\n");
|
||||
else
|
||||
{
|
||||
for (i = 0; i < si->sn_prl_ga.ga_len; ++i)
|
||||
/* Keep going till the end of file, so that trailing
|
||||
* continuation lines are listed. */
|
||||
for (i = 0; ; ++i)
|
||||
{
|
||||
if (vim_fgets(IObuff, IOSIZE, sfd))
|
||||
break;
|
||||
pp = &PRL_ITEM(si, i);
|
||||
if (pp->snp_count > 0)
|
||||
if (i < si->sn_prl_ga.ga_len
|
||||
&& (pp = &PRL_ITEM(si, i))->snp_count > 0)
|
||||
{
|
||||
fprintf(fd, "%5d ", pp->snp_count);
|
||||
if (profile_equal(&pp->sn_prl_total, &pp->sn_prl_self))
|
||||
@@ -4307,27 +4309,6 @@ do_source(
|
||||
save_sourcing_lnum = sourcing_lnum;
|
||||
sourcing_lnum = 0;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
cookie.conv.vc_type = CONV_NONE; /* no conversion */
|
||||
|
||||
/* Read the first line so we can check for a UTF-8 BOM. */
|
||||
firstline = getsourceline(0, (void *)&cookie, 0);
|
||||
if (firstline != NULL && STRLEN(firstline) >= 3 && firstline[0] == 0xef
|
||||
&& firstline[1] == 0xbb && firstline[2] == 0xbf)
|
||||
{
|
||||
/* Found BOM; setup conversion, skip over BOM and recode the line. */
|
||||
convert_setup(&cookie.conv, (char_u *)"utf-8", p_enc);
|
||||
p = string_convert(&cookie.conv, firstline + 3, NULL);
|
||||
if (p == NULL)
|
||||
p = vim_strsave(firstline + 3);
|
||||
if (p != NULL)
|
||||
{
|
||||
vim_free(firstline);
|
||||
firstline = p;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef STARTUPTIME
|
||||
if (time_fd != NULL)
|
||||
time_push(&tv_rel, &tv_start);
|
||||
@@ -4420,6 +4401,27 @@ do_source(
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
cookie.conv.vc_type = CONV_NONE; /* no conversion */
|
||||
|
||||
/* Read the first line so we can check for a UTF-8 BOM. */
|
||||
firstline = getsourceline(0, (void *)&cookie, 0);
|
||||
if (firstline != NULL && STRLEN(firstline) >= 3 && firstline[0] == 0xef
|
||||
&& firstline[1] == 0xbb && firstline[2] == 0xbf)
|
||||
{
|
||||
/* Found BOM; setup conversion, skip over BOM and recode the line. */
|
||||
convert_setup(&cookie.conv, (char_u *)"utf-8", p_enc);
|
||||
p = string_convert(&cookie.conv, firstline + 3, NULL);
|
||||
if (p == NULL)
|
||||
p = vim_strsave(firstline + 3);
|
||||
if (p != NULL)
|
||||
{
|
||||
vim_free(firstline);
|
||||
firstline = p;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Call do_cmdline, which will call getsourceline() to get the lines.
|
||||
*/
|
||||
@@ -4902,7 +4904,8 @@ script_line_start(void)
|
||||
{
|
||||
/* Grow the array before starting the timer, so that the time spent
|
||||
* here isn't counted. */
|
||||
(void)ga_grow(&si->sn_prl_ga, (int)(sourcing_lnum - si->sn_prl_ga.ga_len));
|
||||
(void)ga_grow(&si->sn_prl_ga,
|
||||
(int)(sourcing_lnum - si->sn_prl_ga.ga_len));
|
||||
si->sn_prl_idx = sourcing_lnum - 1;
|
||||
while (si->sn_prl_ga.ga_len <= si->sn_prl_idx
|
||||
&& si->sn_prl_ga.ga_len < si->sn_prl_ga.ga_maxlen)
|
||||
@@ -4937,7 +4940,7 @@ script_line_exec(void)
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when done with a function line.
|
||||
* Called when done with a script line.
|
||||
*/
|
||||
void
|
||||
script_line_end(void)
|
||||
|
||||
+10
-6
@@ -7241,10 +7241,14 @@ ex_quit(exarg_T *eap)
|
||||
wp = curwin;
|
||||
|
||||
#ifdef FEAT_AUTOCMD
|
||||
apply_autocmds(EVENT_QUITPRE, NULL, NULL, FALSE, curbuf);
|
||||
/* Refuse to quit when locked or when the buffer in the last window is
|
||||
* being closed (can only happen in autocommands). */
|
||||
if (curbuf_locked() || !win_valid(wp)
|
||||
/* Refuse to quit when locked. */
|
||||
if (curbuf_locked())
|
||||
return;
|
||||
apply_autocmds(EVENT_QUITPRE, NULL, NULL, FALSE, wp->w_buffer);
|
||||
/* Bail out when autocommands closed the window.
|
||||
* Refuse to quit when the buffer in the last window is being closed (can
|
||||
* only happen in autocommands). */
|
||||
if (!win_valid(wp)
|
||||
|| (wp->w_buffer->b_nwindows == 1 && wp->w_buffer->b_locked > 0))
|
||||
return;
|
||||
#endif
|
||||
@@ -7258,8 +7262,8 @@ ex_quit(exarg_T *eap)
|
||||
*/
|
||||
if (check_more(FALSE, eap->forceit) == OK && only_one_window())
|
||||
exiting = TRUE;
|
||||
if ((!buf_hide(curbuf)
|
||||
&& check_changed(curbuf, (p_awa ? CCGD_AW : 0)
|
||||
if ((!buf_hide(wp->w_buffer)
|
||||
&& check_changed(wp->w_buffer, (p_awa ? CCGD_AW : 0)
|
||||
| (eap->forceit ? CCGD_FORCEIT : 0)
|
||||
| CCGD_EXCMD))
|
||||
|| check_more(TRUE, eap->forceit) == FAIL
|
||||
|
||||
+29
-7
@@ -145,6 +145,19 @@ sort_func_compare(const void *s1, const void *s2);
|
||||
static void set_search_match(pos_T *t);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef FEAT_AUTOCMD
|
||||
static void
|
||||
trigger_cmd_autocmd(int typechar, int evt)
|
||||
{
|
||||
char_u typestr[2];
|
||||
|
||||
typestr[0] = typechar;
|
||||
typestr[1] = NUL;
|
||||
apply_autocmds(evt, typestr, typestr, FALSE, curbuf);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* getcmdline() - accept a command line starting with firstc.
|
||||
*
|
||||
@@ -222,6 +235,9 @@ getcmdline(
|
||||
* custom status line may invoke ":normal". */
|
||||
struct cmdline_info save_ccline;
|
||||
#endif
|
||||
#ifdef FEAT_AUTOCMD
|
||||
int cmdline_type;
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_EVAL
|
||||
if (firstc == -1)
|
||||
@@ -349,6 +365,12 @@ getcmdline(
|
||||
* terminal mode set to cooked. Need to set raw mode here then. */
|
||||
settmode(TMODE_RAW);
|
||||
|
||||
#ifdef FEAT_AUTOCMD
|
||||
/* Trigger CmdlineEnter autocommands. */
|
||||
cmdline_type = firstc == NUL ? '-' : firstc;
|
||||
trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINEENTER);
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_CMDHIST
|
||||
init_history();
|
||||
hiscnt = hislen; /* set hiscnt to impossible history value */
|
||||
@@ -2093,6 +2115,11 @@ returncmd:
|
||||
if (some_key_typed)
|
||||
need_wait_return = FALSE;
|
||||
|
||||
#ifdef FEAT_AUTOCMD
|
||||
/* Trigger CmdlineLeave autocommands. */
|
||||
trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINELEAVE);
|
||||
#endif
|
||||
|
||||
State = save_State;
|
||||
#ifdef USE_IM_CONTROL
|
||||
if (b_im_ptr != NULL && *b_im_ptr != B_IMODE_LMAP)
|
||||
@@ -6848,9 +6875,6 @@ open_cmdwin(void)
|
||||
linenr_T lnum;
|
||||
int histtype;
|
||||
garray_T winsizes;
|
||||
#ifdef FEAT_AUTOCMD
|
||||
char_u typestr[2];
|
||||
#endif
|
||||
int save_restart_edit = restart_edit;
|
||||
int save_State = State;
|
||||
int save_exmode = exmode_active;
|
||||
@@ -6979,9 +7003,7 @@ open_cmdwin(void)
|
||||
|
||||
# ifdef FEAT_AUTOCMD
|
||||
/* Trigger CmdwinEnter autocommands. */
|
||||
typestr[0] = cmdwin_type;
|
||||
typestr[1] = NUL;
|
||||
apply_autocmds(EVENT_CMDWINENTER, typestr, typestr, FALSE, curbuf);
|
||||
trigger_cmd_autocmd(cmdwin_type, EVENT_CMDWINENTER);
|
||||
if (restart_edit != 0) /* autocmd with ":startinsert" */
|
||||
stuffcharReadbuff(K_NOP);
|
||||
# endif
|
||||
@@ -7004,7 +7026,7 @@ open_cmdwin(void)
|
||||
# endif
|
||||
|
||||
/* Trigger CmdwinLeave autocommands. */
|
||||
apply_autocmds(EVENT_CMDWINLEAVE, typestr, typestr, FALSE, curbuf);
|
||||
trigger_cmd_autocmd(cmdwin_type, EVENT_CMDWINLEAVE);
|
||||
|
||||
# ifdef FEAT_FOLDING
|
||||
/* Restore KeyTyped in case it is modified by autocommands */
|
||||
|
||||
@@ -7769,6 +7769,8 @@ static struct event_name
|
||||
{"BufWritePost", EVENT_BUFWRITEPOST},
|
||||
{"BufWritePre", EVENT_BUFWRITEPRE},
|
||||
{"BufWriteCmd", EVENT_BUFWRITECMD},
|
||||
{"CmdlineEnter", EVENT_CMDLINEENTER},
|
||||
{"CmdlineLeave", EVENT_CMDLINELEAVE},
|
||||
{"CmdwinEnter", EVENT_CMDWINENTER},
|
||||
{"CmdwinLeave", EVENT_CMDWINLEAVE},
|
||||
{"CmdUndefined", EVENT_CMDUNDEFINED},
|
||||
|
||||
@@ -779,3 +779,39 @@ func Test_BufLeave_Wipe()
|
||||
" check that bufinfo doesn't contain a pointer to freed memory
|
||||
call test_garbagecollect_now()
|
||||
endfunc
|
||||
|
||||
func Test_QuitPre()
|
||||
edit Xfoo
|
||||
let winid = win_getid(winnr())
|
||||
split Xbar
|
||||
au! QuitPre * let g:afile = expand('<afile>')
|
||||
" Close the other window, <afile> should be correct.
|
||||
exe win_id2win(winid) . 'q'
|
||||
call assert_equal('Xfoo', g:afile)
|
||||
|
||||
unlet g:afile
|
||||
bwipe Xfoo
|
||||
bwipe Xbar
|
||||
endfunc
|
||||
|
||||
func Test_Cmdline()
|
||||
au! CmdlineEnter : let g:entered = expand('<afile>')
|
||||
au! CmdlineLeave : let g:left = expand('<afile>')
|
||||
let g:entered = 0
|
||||
let g:left = 0
|
||||
call feedkeys(":echo 'hello'\<CR>", 'xt')
|
||||
call assert_equal(':', g:entered)
|
||||
call assert_equal(':', g:left)
|
||||
au! CmdlineEnter
|
||||
au! CmdlineLeave
|
||||
|
||||
au! CmdlineEnter / let g:entered = expand('<afile>')
|
||||
au! CmdlineLeave / let g:left = expand('<afile>')
|
||||
let g:entered = 0
|
||||
let g:left = 0
|
||||
call feedkeys("/hello<CR>", 'xt')
|
||||
call assert_equal('/', g:entered)
|
||||
call assert_equal('/', g:left)
|
||||
au! CmdlineEnter
|
||||
au! CmdlineLeave
|
||||
endfunc
|
||||
|
||||
@@ -1373,3 +1373,16 @@ func Test_edit_complete_very_long_name()
|
||||
endif
|
||||
set swapfile&
|
||||
endfunc
|
||||
|
||||
func Test_edit_quit()
|
||||
edit foo.txt
|
||||
split
|
||||
new
|
||||
call setline(1, 'hello')
|
||||
3wincmd w
|
||||
redraw!
|
||||
call assert_fails('1q', 'E37:')
|
||||
bwipe! foo.txt
|
||||
only
|
||||
endfunc
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ func Test_profile_file()
|
||||
call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[3])
|
||||
call assert_equal('', lines[4])
|
||||
call assert_equal('count total (s) self (s)', lines[5])
|
||||
call assert_equal(' func! Foo()', lines[6])
|
||||
call assert_match(' 2 0.\d\+ func! Foo()', lines[6])
|
||||
call assert_equal(' endfunc', lines[7])
|
||||
" Loop iterates 10 times. Since script runs twice, body executes 20 times.
|
||||
" First line of loop executes one more time than body to detect end of loop.
|
||||
@@ -132,6 +132,42 @@ func Test_profile_file()
|
||||
call delete('Xprofile_file.log')
|
||||
endfunc
|
||||
|
||||
func Test_profile_file_with_cont()
|
||||
let lines = [
|
||||
\ 'echo "hello',
|
||||
\ ' \ world"',
|
||||
\ 'echo "foo ',
|
||||
\ ' \bar"',
|
||||
\ ]
|
||||
|
||||
call writefile(lines, 'Xprofile_file.vim')
|
||||
call system(v:progpath
|
||||
\ . ' -es --clean'
|
||||
\ . ' -c "profile start Xprofile_file.log"'
|
||||
\ . ' -c "profile file Xprofile_file.vim"'
|
||||
\ . ' -c "so Xprofile_file.vim"'
|
||||
\ . ' -c "qall!"')
|
||||
call assert_equal(0, v:shell_error)
|
||||
|
||||
let lines = readfile('Xprofile_file.log')
|
||||
call assert_equal(11, len(lines))
|
||||
|
||||
call assert_match('^SCRIPT .*Xprofile_file.vim$', lines[0])
|
||||
call assert_equal('Sourced 1 time', lines[1])
|
||||
call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[2])
|
||||
call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[3])
|
||||
call assert_equal('', lines[4])
|
||||
call assert_equal('count total (s) self (s)', lines[5])
|
||||
call assert_match(' 1 0.\d\+ echo "hello', lines[6])
|
||||
call assert_equal(' \ world"', lines[7])
|
||||
call assert_match(' 1 0.\d\+ echo "foo ', lines[8])
|
||||
call assert_equal(' \bar"', lines[9])
|
||||
call assert_equal('', lines[10])
|
||||
|
||||
call delete('Xprofile_file.vim')
|
||||
call delete('Xprofile_file.log')
|
||||
endfunc
|
||||
|
||||
func Test_profile_completion()
|
||||
call feedkeys(":profile \<C-A>\<C-B>\"\<CR>", 'tx')
|
||||
call assert_equal('"profile continue file func pause start', @:)
|
||||
|
||||
@@ -776,6 +776,14 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1207,
|
||||
/**/
|
||||
1206,
|
||||
/**/
|
||||
1205,
|
||||
/**/
|
||||
1204,
|
||||
/**/
|
||||
1203,
|
||||
/**/
|
||||
|
||||
@@ -1298,6 +1298,8 @@ enum auto_event
|
||||
EVENT_BUFWRITEPOST, /* after writing a buffer */
|
||||
EVENT_BUFWRITEPRE, /* before writing a buffer */
|
||||
EVENT_BUFWRITECMD, /* write buffer using command */
|
||||
EVENT_CMDLINEENTER, /* after entering the command line */
|
||||
EVENT_CMDLINELEAVE, /* before leaving the command line */
|
||||
EVENT_CMDWINENTER, /* after entering the cmdline window */
|
||||
EVENT_CMDWINLEAVE, /* before leaving the cmdline window */
|
||||
EVENT_COLORSCHEME, /* after loading a colorscheme */
|
||||
|
||||
Reference in New Issue
Block a user