Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into tabsidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
rbtnn committed Jan 11, 2025
2 parents 88ee2e2 + 5eaacef commit 984aabb
Show file tree
Hide file tree
Showing 17 changed files with 231 additions and 10 deletions.
8 changes: 5 additions & 3 deletions runtime/doc/syntax.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*syntax.txt* For Vim version 9.1. Last change: 2024 Dec 16
*syntax.txt* For Vim version 9.1. Last change: 2025 Jan 11


VIM REFERENCE MANUAL by Bram Moolenaar
Expand Down Expand Up @@ -5854,9 +5854,11 @@ PmenuSbar Popup menu: Scrollbar.
*hl-PmenuThumb*
PmenuThumb Popup menu: Thumb of the scrollbar.
*hl-PmenuMatch*
PmenuMatch Popup menu: Matched text in normal item.
PmenuMatch Popup menu: Matched text in normal item. Applied in
combination with |hl-Pmenu|.
*hl-PmenuMatchSel*
PmenuMatchSel Popup menu: Matched text in selected item.
PmenuMatchSel Popup menu: Matched text in selected item. Applied in
combination with |hl-PmenuSel|.
*hl-ComplMatchIns*
ComplMatchIns Matched text of the currently inserted completion.
*hl-PopupNotification*
Expand Down
1 change: 1 addition & 0 deletions runtime/doc/tags
Original file line number Diff line number Diff line change
Expand Up @@ -7941,6 +7941,7 @@ gf editing.txt /*gf*
gg motion.txt /*gg*
gh visual.txt /*gh*
gi insert.txt /*gi*
git-vimdumps terminal.txt /*git-vimdumps*
gj motion.txt /*gj*
gk motion.txt /*gk*
glob() builtin.txt /*glob()*
Expand Down
6 changes: 6 additions & 0 deletions runtime/doc/terminal.txt
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,12 @@ ConPTY problems have been fixed "winpty" will be preferred.
Environment variables are used to pass information to the running job:
VIM_SERVERNAME v:servername

*git-vimdumps*
There exists a git-difftool extension called `git-vimdumps` that can be used
to conveniently inspect screendump files and diff them. Please see in the Vim
Repository the file `src/testdir/commondumps.vim` on how to create and use
this git extension.

==============================================================================
2. Terminal functions *terminal-function-details*

Expand Down
3 changes: 3 additions & 0 deletions runtime/syntax/testdir/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ You can now examine the extracted screendumps:
Viewing generated screendumps (submitted for a pull request)
------------------------------------------------------------

Note: There is also a "git difftool" extension described in
src/testdir/commondumps.vim

First, you need to check out the topic branch with the proposed changes and
write down a difference list between the HEAD commit (index) and its parent
commit with respect to the changed "dumps" filenames:
Expand Down
4 changes: 4 additions & 0 deletions src/arglist.c
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,10 @@ do_arg_all(

tabpage_T *new_lu_tp = curtab;

// Stop Visual mode, the cursor and "VIsual" may very well be invalid after
// switching to another buffer.
reset_VIsual_and_resel();

// Try closing all windows that are not in the argument list.
// Also close windows that are not full width;
// When 'hidden' or "forceit" set the buffer becomes hidden.
Expand Down
2 changes: 1 addition & 1 deletion src/insexpand.c
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ ins_compl_col_range_attr(int col)
if ((get_cot_flags() & COT_FUZZY))
return -1;

if (col >= (compl_col + (int)compl_leader.length) && col < compl_ins_end_col)
if (col >= (compl_col + (int)ins_compl_leader_len()) && col < compl_ins_end_col)
return syn_name2attr((char_u *)"ComplMatchIns");

return -1;
Expand Down
4 changes: 4 additions & 0 deletions src/misc1.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,11 +543,15 @@ plines_m_win(win_T *wp, linenr_T first, linenr_T last, int max)
gchar_pos(pos_T *pos)
{
char_u *ptr;
int ptrlen;

// When searching columns is sometimes put at the end of a line.
if (pos->col == MAXCOL)
return NUL;
ptrlen = ml_get_len(pos->lnum);
ptr = ml_get_pos(pos);
if (pos->col > ptrlen)
return NUL;
if (has_mbyte)
return (*mb_ptr2char)(ptr);
return (int)*ptr;
Expand Down
3 changes: 2 additions & 1 deletion src/ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -2586,6 +2586,7 @@ charwise_block_prep(
colnr_T startcol = 0, endcol = MAXCOL;
colnr_T cs, ce;
char_u *p;
int plen = ml_get_len(lnum);

p = ml_get(lnum);
bdp->startspaces = 0;
Expand Down Expand Up @@ -2646,7 +2647,7 @@ charwise_block_prep(
else
bdp->textlen = endcol - startcol + inclusive;
bdp->textcol = startcol;
bdp->textstart = p + startcol;
bdp->textstart = startcol <= plen ? p + startcol : p;
}

/*
Expand Down
5 changes: 5 additions & 0 deletions src/popupmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,18 @@ pum_compute_text_attrs(char_u *text, hlf_T hlf, int user_hlattr)
if (char_pos == ((int_u *)ga->ga_data)[i])
{
new_attr = highlight_attr[is_select ? HLF_PMSI : HLF_PMNI];
new_attr = hl_combine_attr(highlight_attr[hlf], new_attr);
break;
}
}
}
else if (matched_start && ptr < text + leader_len)
{
new_attr = highlight_attr[is_select ? HLF_PMSI : HLF_PMNI];
new_attr = hl_combine_attr(highlight_attr[hlf], new_attr);
}

new_attr = hl_combine_attr(highlight_attr[HLF_PNI], new_attr);
if (user_hlattr > 0)
new_attr = hl_combine_attr(new_attr, user_hlattr);

Expand Down
2 changes: 2 additions & 0 deletions src/testdir/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ You can now examine the extracted screendumps:

VIEWING GENERATED SCREENDUMPS (submitted for a pull request):

Note: There is also a "git difftool" extension described in ./commondumps.vim.

First, you need to check out the topic branch with the proposed changes and
write down a difference list between the HEAD commit (index) and its parent
commit with respect to the changed "dumps" filenames:
Expand Down
110 changes: 109 additions & 1 deletion src/testdir/commondumps.vim
Original file line number Diff line number Diff line change
@@ -1,7 +1,112 @@
vim9script

# (Script-local.)
# See below on how to configure the git difftool extension

# Extend "git difftool" with the capability for loading screendump files.
if v:progname =~? '\<g\=vimdiff$'
# Let "(g)vimdiff" render other files.
if [argv(0), argv(1)]
->filter((_: number, fname: string) =>
fname =~? '^\%(/dev/null\|.\+\.dump\)$')
->len() == 2
try
if argv(0) ==? '/dev/null'
term_dumpload(argv(1))
elseif argv(1) ==? '/dev/null'
term_dumpload(argv(0))
else
term_dumpdiff(argv(0), argv(1))
endif
finally
silent bwipeout 1 2
endtry
endif

# Always stop from further sourcing this script for "(g)vimdiff".
finish
endif

# CONSIDER ALTERNATIVES FOR ENABLING THE ABOVE EXTENSION.
#
# For convenience, it is assumed that there is a defined "$VIM_FORK_PATHNAME"
# environment variable holding an absolute pathname for the root directory of
# this repository.
#
#
# A. USE Git FOR CONFIGURATION.
#
# Define the following Git variables with "git config --edit --local" (where
# the "vimdumps" name is arbitrary):
#
# ------------------------------------------------------------------------------
# [diff]
# tool = vimdumps
# [difftool.vimdumps]
# cmd = vimdiff -S "${VIM_FORK_PATHNAME:?}"/src/testdir/commondumps.vim -o -- "$LOCAL" "$REMOTE"
# ------------------------------------------------------------------------------
#
# Rendered screendump files (among other files) between revisions can now be
# compared, two at a time, by using "git difftool", e.g.:
# git difftool 50423ab8~1 50423ab8
# git difftool 50423ab8~1 50423ab8 -- '**/*.dump'
#
# The raw files can also be examined:
# :all
#
#
# B. USE Bash FOR CONFIGURATION (on Debian GNU/Linux).
#
# 1. Make an alias that sources this file, e.g.:
# alias git_vimdiff="git difftool -x 'vimdiff -S "${VIM_FORK_PATHNAME:?}"/vim/src/testdir/commondumps.vim -o --'"
#
# 2. Enable programmable completion for the alias, e.g.:
# cat ~/.local/share/bash-completion/completions/git_vimdiff
#
# ------------------------------------------------------------------------------
# ## Consider (un)setting "$BASH_COMPLETION_USER_DIR" and/or "$XDG_DATA_HOME" so
# ## that this file can be found and sourced; look for these variables in the
# ## "/usr/share/bash-completion/bash_completion" script.
# ##
# ## Look for __git_complete() examples in the header comment of the sourced
# ## "/usr/share/bash-completion/completions/git" script.
# [ -r /usr/share/bash-completion/completions/git ] &&
# . /usr/share/bash-completion/completions/git &&
# __git_complete git_vimdiff _git_difftool
# ------------------------------------------------------------------------------
#
# Rendered screendump files (among other files) between revisions can now be
# compared, two at a time, by using the alias, e.g.:
# git_vimdiff 50423ab8~1 50423ab8
# git_vimdiff 50423ab8~1 50423ab8 -- '**/*.dump'
#
# The raw files can also be examined:
# :all


# Script-local functions
#
# Fold the difference part and the bottom part when the top and the bottom
# parts are identical.
def FoldDumpDiffCopy()
try
normal mc
# Shape the pattern after get_separator() from "terminal.c".
const separator: string = '^\(=\+\)\=\s\S.*\.dump\s\1$'
const start_lnum: number = search(separator, 'eW', (line('$') / 2))
if start_lnum > 0
const end_lnum: number = search(separator, 'eW')
if end_lnum > 0 && getline((start_lnum + 1), (end_lnum - 1))
->filter((_: number, line: string) => line !~ '^\s\+$')
->empty()
setlocal foldenable foldmethod=manual
exec 'normal ' .. start_lnum .. 'GzfG'
endif
endif
finally
normal `c
endtry
enddef

# Render a loaded screendump file or the difference of a loaded screendump
# file and its namesake file from the "dumps" directory.
def Render()
Expand All @@ -13,6 +118,7 @@ def Render()
fnamemodify(failed_fname, ':p:h:h') .. '/dumps')
if filereadable(dumps_fname)
term_dumpdiff(failed_fname, dumps_fname)
FoldDumpDiffCopy()
else
term_dumpload(failed_fname)
endif
Expand All @@ -21,6 +127,8 @@ def Render()
endtry
enddef

# Public functions
#
# Search for the "failed" directory in the passed _subtreedirname_ directories
# (usually "\<src\>" or "\<syntax\>") and, if found, select its passed _count_
# occurrence, add all its "*.dump" files to the argument list and list them;
Expand Down
20 changes: 20 additions & 0 deletions src/testdir/dumps/Test_pum_highlights_18.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
|f+0&#ffffff0|b> @72
|f+0#40ffff15#e0e0e08|o+0#0000001&@1|B+0#40ffff15&|a+0#0000001&|z| @1|f|o@1|k|i|n|d| | +0#4040ff13#ffffff0@58
|f+0&#ffd7ff255|o+0#0000001&@1|b+0#4040ff13&|a+0#0000001&|r| @1|f|o@1|k|i|n|d| | +0#4040ff13#ffffff0@58
|f+0&#ffd7ff255|o+0#0000001&@1|b+0#4040ff13&|a+0#0000001&|l|a| |f|o@1|k|i|n|d| | +0#4040ff13#ffffff0@58
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|-+2#0000000&@1| |O|m|n|i| |c|o|m|p|l|e|t|i|o|n| |(|^|O|^|N|^|P|)| |m+0#00e0003&|a|t|c|h| |1| |o|f| |9| +0#0000000&@34
20 changes: 20 additions & 0 deletions src/testdir/dumps/Test_pum_matchins_combine_09.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
|f+8&#40ff4011> @73
|~+0#4040ff13#4040ff13| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|-+2#0000000&@1| |K|e|y|w|o|r|d| |c|o|m|p|l|e|t|i|o|n| |(|^|N|^|P|)| |P+0#ffffff16#e000002|a|t@1|e|r|n| |n|o|t| |f|o|u|n|d| +0#0000000#4040ff13@28
17 changes: 17 additions & 0 deletions src/testdir/test_popup.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,16 @@ func Test_pum_highlights_match()
call term_sendkeys(buf, "\<ESC>S/non_existing_folder\<C-X>\<C-F>")
call TermWait(buf, 50)
call VerifyScreenDump(buf, 'Test_pum_highlights_15', {})
call term_sendkeys(buf, "\<C-E>\<Esc>")

call term_sendkeys(buf, ":hi PmenuMatchSel ctermfg=14\<CR>")
call TermWait(buf, 50)
call term_sendkeys(buf, ":hi PmenuMatch ctermfg=12\<CR>")
call term_sendkeys(buf, ":set cot=menu,noinsert,fuzzy\<CR>")
call term_sendkeys(buf, "S\<C-X>\<C-O>")
call TermWait(buf, 50)
call term_sendkeys(buf, "fb")
call VerifyScreenDump(buf, 'Test_pum_highlights_18', {})

call term_sendkeys(buf, "\<C-E>\<Esc>")
call TermWait(buf)
Expand Down Expand Up @@ -1829,6 +1839,13 @@ func Test_pum_matchins_highlight_combine()
call term_sendkeys(buf, "S\<C-X>\<C-O>f\<C-N>")
call VerifyScreenDump(buf, 'Test_pum_matchins_combine_08', {})
call term_sendkeys(buf, "\<C-E>\<Esc>")
call TermWait(buf)

call term_sendkeys(buf, ":set cot-=fuzzy\<CR>")
call TermWait(buf)
call term_sendkeys(buf, "Sf\<C-N>")
call VerifyScreenDump(buf, 'Test_pum_matchins_combine_09', {})
call term_sendkeys(buf, "\<C-E>\<Esc>")

call StopVimInTerminal(buf)
endfunc
Expand Down
2 changes: 2 additions & 0 deletions src/testdir/test_termdebug.vim
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ packadd termdebug
" should be the first test to run, since it validates the window layout with
" win ids
func Test_termdebug_basic()
let g:test_is_flaky = 1
let bin_name = 'XTD_basic'
let src_name = bin_name .. '.c'
call s:generate_files(bin_name)
Expand Down Expand Up @@ -579,6 +580,7 @@ endfunction

function Test_termdebug_config_types()
" TODO Remove the deprecated features after 1 Jan 2025.
let g:test_is_flaky = 1
let g:termdebug_config = {}
let s:error_message = 'Deprecation Warning:'
call assert_true(maparg('K', 'n', 0, 1)->empty())
Expand Down
Loading

0 comments on commit 984aabb

Please sign in to comment.