aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/autoload/zip.vim37
-rw-r--r--runtime/compiler/javac.vim9
-rw-r--r--runtime/doc/options.txt3
-rw-r--r--runtime/doc/quickfix.txt7
-rw-r--r--runtime/doc/various.txt2
-rw-r--r--runtime/indent/kdl.vim18
-rw-r--r--runtime/lua/vim/_meta/options.lua3
-rw-r--r--runtime/lua/vim/filetype/detect.lua1
-rw-r--r--runtime/syntax/html.vim2
-rw-r--r--runtime/syntax/java.vim56
-rw-r--r--runtime/syntax/kdl.vim13
-rw-r--r--src/nvim/insexpand.c8
-rw-r--r--src/nvim/options.lua3
-rw-r--r--src/nvim/popupmenu.c39
-rw-r--r--test/functional/ui/popupmenu_spec.lua71
-rw-r--r--test/old/testdir/test_cmdline.vim18
-rw-r--r--test/old/testdir/test_filetype.vim1
-rw-r--r--test/old/testdir/test_ins_complete.vim13
-rw-r--r--test/old/testdir/test_popup.vim38
19 files changed, 277 insertions, 65 deletions
diff --git a/runtime/autoload/zip.vim b/runtime/autoload/zip.vim
index c0034f8a7a..d0e706e83a 100644
--- a/runtime/autoload/zip.vim
+++ b/runtime/autoload/zip.vim
@@ -4,17 +4,18 @@
" Version: 33
" Maintainer: This runtime file is looking for a new maintainer.
" Former Maintainer: Charles E Campbell
+" Last Change:
+" 2024 Jun 16 by Vim Project: handle whitespace on Windows properly (#14998)
" License: Vim License (see vim's :help license)
-" Copyright: Copyright (C) 2005-2019 Charles E. Campbell {{{1
-" Permission is hereby granted to use and distribute this code,
-" with or without modifications, provided that this copyright
-" notice is copied with it. Like anything else that's free,
-" zip.vim and zipPlugin.vim are provided *as is* and comes with
-" no warranty of any kind, either expressed or implied. By using
-" this plugin, you agree that in no event will the copyright
-" holder be liable for any damages resulting from the use
-" of this software.
-"redraw!|call DechoSep()|call inputsave()|call input("Press <cr> to continue")|call inputrestore()
+" Copyright: Copyright (C) 2005-2019 Charles E. Campbell {{{1
+" Permission is hereby granted to use and distribute this code,
+" with or without modifications, provided that this copyright
+" notice is copied with it. Like anything else that's free,
+" zip.vim and zipPlugin.vim are provided *as is* and comes with
+" no warranty of any kind, either expressed or implied. By using
+" this plugin, you agree that in no event will the copyright
+" holder be liable for any damages resulting from the use
+" of this software.
" ---------------------------------------------------------------------
" Load Once: {{{1
@@ -214,7 +215,6 @@ endfun
" ---------------------------------------------------------------------
" zip#Read: {{{2
fun! zip#Read(fname,mode)
-" call Dfunc("zip#Read(fname<".a:fname.">,mode=".a:mode.")")
let repkeep= &report
set report=10
@@ -226,15 +226,12 @@ fun! zip#Read(fname,mode)
let fname = substitute(a:fname,'^.\{-}zipfile://.\{-}::\([^\\].*\)$','\1','')
let fname = substitute(fname, '[', '[[]', 'g')
endif
-" call Decho("zipfile<".zipfile.">")
-" call Decho("fname <".fname.">")
" sanity check
if !executable(substitute(g:zip_unzipcmd,'\s\+.*$','',''))
redraw!
echohl Error | echo "***error*** (zip#Read) sorry, your system doesn't appear to have the ".g:zip_unzipcmd." program" | echohl None
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
let &report= repkeep
-" call Dret("zip#Write")
return
endif
@@ -242,10 +239,8 @@ fun! zip#Read(fname,mode)
" exe "keepj sil! r! ".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fnameescape(fname),1)
" but allows zipfile://... entries in quickfix lists
let temp = tempname()
-" call Decho("using temp file<".temp.">")
let fn = expand('%:p')
- exe "sil! !".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fnameescape(fname),1).' > '.temp
-" call Decho("exe sil! !".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fnameescape(fname),1).' > '.temp)
+ exe "sil! !".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fname,1).' > '.temp
sil exe 'keepalt file '.temp
sil keepj e!
sil exe 'keepalt file '.fnameescape(fn)
@@ -254,11 +249,9 @@ fun! zip#Read(fname,mode)
filetype detect
" cleanup
- " keepj 0d " used to be needed for the ...r! ... method
set nomod
let &report= repkeep
-" call Dret("zip#Read")
endfun
" ---------------------------------------------------------------------
@@ -422,7 +415,6 @@ endfun
" ---------------------------------------------------------------------
" s:Escape: {{{2
fun! s:Escape(fname,isfilt)
-" call Dfunc("QuoteFileDir(fname<".a:fname."> isfilt=".a:isfilt.")")
if exists("*shellescape")
if a:isfilt
let qnameq= shellescape(a:fname,1)
@@ -432,7 +424,10 @@ fun! s:Escape(fname,isfilt)
else
let qnameq= g:zip_shq.escape(a:fname,g:zip_shq).g:zip_shq
endif
-" call Dret("QuoteFileDir <".qnameq.">")
+ if exists("+shellslash") && &shellslash && &shell =~ "cmd.exe"
+ " renormalize directory separator on Windows
+ let qnameq=substitute(qnameq, '/', '\\', 'g')
+ endif
return qnameq
endfun
diff --git a/runtime/compiler/javac.vim b/runtime/compiler/javac.vim
index f5fe84124f..9bd4cdf270 100644
--- a/runtime/compiler/javac.vim
+++ b/runtime/compiler/javac.vim
@@ -1,7 +1,7 @@
" Vim compiler file
" Compiler: Java Development Kit Compiler
" Maintainer: Doug Kearns <dougkearns@gmail.com>
-" Last Change: 2024 Apr 03
+" Last Change: 2024 Jun 14
if exists("current_compiler")
finish
@@ -11,7 +11,12 @@ let current_compiler = "javac"
let s:cpo_save = &cpo
set cpo&vim
-CompilerSet makeprg=javac
+if exists("g:javac_makeprg_params")
+ execute $'CompilerSet makeprg=javac\ {escape(g:javac_makeprg_params, ' \|"')}'
+else
+ CompilerSet makeprg=javac
+endif
+
CompilerSet errorformat=%E%f:%l:\ error:\ %m,
\%W%f:%l:\ warning:\ %m,
\%-Z%p^,
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 244465ed6e..1b71050620 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -3842,6 +3842,9 @@ A jump table for the options with a short description can be found at |Q_op|.
between tabs and spaces and for trailing blanks. Further changed by
the 'listchars' option.
+ When 'listchars' does not contain "tab" field, tabs are shown as "^I"
+ or "<09>", like how unprintable characters are displayed.
+
The cursor is displayed at the start of the space a Tab character
occupies, not at the end as usual in Normal mode. To get this cursor
position while displaying Tabs with spaces, use: >vim
diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt
index 897e503fc4..9ac7492b9b 100644
--- a/runtime/doc/quickfix.txt
+++ b/runtime/doc/quickfix.txt
@@ -1288,6 +1288,13 @@ g:compiler_gcc_ignore_unmatched_lines
commands run from make are generating false
positives.
+JAVAC *compiler-javac*
+
+Commonly used compiler options can be added to 'makeprg' by setting the
+g:javac_makeprg_params variable. For example: >
+ let g:javac_makeprg_params = "-Xlint:all -encoding utf-8"
+<
+
PANDOC *quickfix-pandoc* *compiler-pandoc*
The Pandoc compiler plugin expects that an output file type extension is
diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt
index 0287271d4c..63fca2c1aa 100644
--- a/runtime/doc/various.txt
+++ b/runtime/doc/various.txt
@@ -140,7 +140,7 @@ gx Opens the current filepath or URL (decided by
:[range]# [count] [flags]
synonym for :number.
- *:#!*
+ *:#!* *vim-shebang*
:#!{anything} Ignored, so that you can start a Vim script with: >
#!vim -S
echo "this is a Vim script"
diff --git a/runtime/indent/kdl.vim b/runtime/indent/kdl.vim
index b1b004d0a2..b0a6bd90d9 100644
--- a/runtime/indent/kdl.vim
+++ b/runtime/indent/kdl.vim
@@ -2,7 +2,7 @@
" Language: KDL
" Author: Aram Drevekenin <aram@poor.dev>
" Maintainer: Yinzuo Jiang <jiangyinzuo@foxmail.com>
-" Last Change: 2024-06-11
+" Last Change: 2024-06-16
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
@@ -14,13 +14,17 @@ setlocal indentexpr=KdlIndent()
let b:undo_indent = "setlocal indentexpr<"
function! KdlIndent(...)
- let line = getline(v:lnum)
+ let line = substitute(getline(v:lnum), '//.*$', '', '')
let previousNum = prevnonblank(v:lnum - 1)
- let previous = getline(previousNum)
+ let previous = substitute(getline(previousNum), '//.*$', '', '')
- if previous =~ "{" && previous !~ "}" && line !~ "}" && line !~ ":$"
- return indent(previousNum) + shiftwidth()
- else
- return indent(previousNum)
+ let l:indent = indent(previousNum)
+ if previous =~ "{" && previous !~ "}"
+ let l:indent += shiftwidth()
endif
+ if line =~ "}" && line !~ "{"
+ let l:indent -= shiftwidth()
+ endif
+ return l:indent
endfunction
+" vim: sw=2 sts=2 et
diff --git a/runtime/lua/vim/_meta/options.lua b/runtime/lua/vim/_meta/options.lua
index befb56d3d5..902df8f7d6 100644
--- a/runtime/lua/vim/_meta/options.lua
+++ b/runtime/lua/vim/_meta/options.lua
@@ -3830,6 +3830,9 @@ vim.go.lw = vim.go.lispwords
--- between tabs and spaces and for trailing blanks. Further changed by
--- the 'listchars' option.
---
+--- When 'listchars' does not contain "tab" field, tabs are shown as "^I"
+--- or "<09>", like how unprintable characters are displayed.
+---
--- The cursor is displayed at the start of the space a Tab character
--- occupies, not at the end as usual in Normal mode. To get this cursor
--- position while displaying Tabs with spaces, use:
diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua
index c56ece6289..fa90c83b81 100644
--- a/runtime/lua/vim/filetype/detect.lua
+++ b/runtime/lua/vim/filetype/detect.lua
@@ -1783,6 +1783,7 @@ local patterns_hashbang = {
['^janet\\>'] = { 'janet', { vim_regex = true } },
['^dart\\>'] = { 'dart', { vim_regex = true } },
['^execlineb\\>'] = { 'execline', { vim_regex = true } },
+ ['^vim\\>'] = { 'vim', { vim_regex = true } },
}
---@private
diff --git a/runtime/syntax/html.vim b/runtime/syntax/html.vim
index c975ae8620..d067dde83c 100644
--- a/runtime/syntax/html.vim
+++ b/runtime/syntax/html.vim
@@ -191,7 +191,7 @@ syn keyword htmlArg contained step title translate typemustmatch
syn match htmlArg contained "\<data-\h\%(\w\|[-.]\)*\%(\_s*=\)\@="
" special characters
-syn match htmlSpecialChar "&#\=[0-9A-Za-z]\{1,8};"
+syn match htmlSpecialChar "&#\=[0-9A-Za-z]\{1,32};"
" Comments (the real ones or the old netscape ones)
if exists("html_wrong_comments")
diff --git a/runtime/syntax/java.vim b/runtime/syntax/java.vim
index 1f71f9e4ee..6f64bdc4ed 100644
--- a/runtime/syntax/java.vim
+++ b/runtime/syntax/java.vim
@@ -3,7 +3,7 @@
" Maintainer: Aliaksei Budavei <0x000c70 AT gmail DOT com>
" Former Maintainer: Claudio Fleiner <claudio@fleiner.com>
" Repository: https://github.com/zzzyxwvut/java-vim.git
-" Last Change: 2024 Jun 10
+" Last Change: 2024 Jun 15
" Please check :help java.vim for comments on some of the options available.
@@ -14,7 +14,6 @@ if !exists("main_syntax")
endif
" we define it here so that included files can test for it
let main_syntax='java'
- syn region javaFold start="{" end="}" transparent fold
endif
let s:cpo_save = &cpo
@@ -40,6 +39,18 @@ else
endfunction
endif
+function! JavaSyntaxFoldTextExpr() abort
+ return getline(v:foldstart) !~ '/\*\+\s*$'
+ \ ? foldtext()
+ \ : printf('+-%s%3d lines: ',
+ \ v:folddashes,
+ \ (v:foldend - v:foldstart + 1)) .
+ \ getline(v:foldstart + 1)
+endfunction
+
+" E120 for "fdt=s:JavaSyntaxFoldTextExpr()" before v8.2.3900.
+setlocal foldtext=JavaSyntaxFoldTextExpr()
+
" Admit the ASCII dollar sign to keyword characters (JLS-17, §3.8):
try
exec 'syntax iskeyword ' . &l:iskeyword . ',$'
@@ -99,7 +110,7 @@ syn match javaClassDecl "\<record\>\%(\s*(\)\@!"
syn match javaClassDecl "^class\>"
syn match javaClassDecl "[^.]\s*\<class\>"ms=s+1
syn match javaAnnotation "@\%(\K\k*\.\)*\K\k*\>"
-syn region javaAnnotation transparent matchgroup=javaAnnotationStart start=/@\%(\K\k*\.\)*\K\k*(/ end=/)/ skip=/\/\*.\{-}\*\/\|\/\/.*$/ contains=javaAnnotation,javaParenT,javaBraces,javaString,javaBoolean,javaNumber,javaTypedef,javaComment,javaLineComment
+syn region javaAnnotation transparent matchgroup=javaAnnotationStart start=/@\%(\K\k*\.\)*\K\k*(/ end=/)/ skip=/\/\*.\{-}\*\/\|\/\/.*$/ contains=javaAnnotation,javaParenT,javaBlock,javaString,javaBoolean,javaNumber,javaTypedef,javaComment,javaLineComment
syn match javaClassDecl "@interface\>"
syn keyword javaBranch break continue nextgroup=javaUserLabelRef skipwhite
syn match javaUserLabelRef "\k\+" contained
@@ -238,7 +249,7 @@ if exists("java_comment_strings")
syn cluster javaCommentSpecial2 add=javaComment2String,javaCommentCharacter,javaNumber,javaStrTempl
endif
-syn region javaComment matchgroup=javaCommentStart start="/\*" end="\*/" contains=@javaCommentSpecial,javaTodo,javaCommentError,javaSpaceError,@Spell
+syn region javaComment matchgroup=javaCommentStart start="/\*" end="\*/" contains=@javaCommentSpecial,javaTodo,javaCommentError,javaSpaceError,@Spell fold
syn match javaCommentStar contained "^\s*\*[^/]"me=e-1
syn match javaCommentStar contained "^\s*\*$"
syn match javaLineComment "//.*" contains=@javaCommentSpecial2,javaTodo,javaCommentMarkupTag,javaSpaceError,@Spell
@@ -269,7 +280,7 @@ if !exists("java_ignore_javadoc") && main_syntax != 'jsp'
call s:ReportOnce(v:exception)
endtry
- syn region javaDocComment start="/\*\*" end="\*/" keepend contains=javaCommentTitle,@javaHtml,javaDocTags,javaDocSeeTag,javaDocCodeTag,javaDocSnippetTag,javaTodo,javaCommentError,javaSpaceError,@Spell
+ syn region javaDocComment start="/\*\*" end="\*/" keepend contains=javaCommentTitle,@javaHtml,javaDocTags,javaDocSeeTag,javaDocCodeTag,javaDocSnippetTag,javaTodo,javaCommentError,javaSpaceError,@Spell fold
exec 'syn region javaCommentTitle contained matchgroup=javaDocComment start="/\*\*" matchgroup=javaCommentTitle end="\.$" end="\.[ \t\r]\@=" end="\%(^\s*\**\s*\)\@' . s:ff.Peek('80', '') . '<=@"me=s-2,he=s-1 end="\*/"me=s-1,he=s-1 contains=@javaHtml,javaCommentStar,javaTodo,javaCommentError,javaSpaceError,@Spell,javaDocTags,javaDocSeeTag,javaDocCodeTag,javaDocSnippetTag'
syn region javaCommentTitle contained matchgroup=javaDocComment start="/\*\*\s*\r\=\n\=\s*\**\s*\%({@return\>\)\@=" matchgroup=javaCommentTitle end="}\%(\s*\.*\)*" contains=@javaHtml,javaCommentStar,javaTodo,javaCommentError,javaSpaceError,@Spell,javaDocTags,javaDocSeeTag,javaDocCodeTag,javaDocSnippetTag
syn region javaDocTags contained start="{@\%(li\%(teral\|nk\%(plain\)\=\)\|inherit[Dd]oc\|doc[rR]oot\|value\)\>" end="}"
@@ -348,8 +359,6 @@ if exists("java_highlight_functions")
" Match: [@ɐ] [abstract] [<α, β>] Τʬ[<γ>][[][]] μʭʭ(/* ... */);
exec 'syn region javaFuncDef start=/' . s:ff.Engine('\%#=2', '') . '^\s\+\%(\%(@\%(\K\k*\.\)*\K\k*\>\)\s\+\)*\%(p\%(ublic\|rotected\|rivate\)\s\+\)\=\%(\%(abstract\|default\)\s\+\|\%(\%(final\|\%(native\|strictfp\)\|s\%(tatic\|ynchronized\)\)\s\+\)*\)\=\%(<.*[[:space:]-]\@' . s:ff.Peek('1', '') . '<!>\s\+\)\=\%(void\|\%(b\%(oolean\|yte\)\|char\|short\|int\|long\|float\|double\|\%(\<\K\k*\>\.\)*\<' . s:ff.UpperCase('[$_[:upper:]]', '[^a-z0-9]') . '\k*\>\%(<[^(){}]*[[:space:]-]\@' . s:ff.Peek('1', '') . '<!>\)\=\)\%(\[\]\)*\)\s\+\<' . s:ff.LowerCase('[$_[:lower:]]', '[^A-Z0-9]') . '\k*\>\s*(/ end=/)/ skip=/\/\*.\{-}\*\/\|\/\/.*$/ contains=@javaFuncParams'
endif
-
- syn match javaBraces "[{}]"
endif
if exists("java_highlight_debug")
@@ -404,14 +413,18 @@ if exists("java_highlight_debug")
endif
if exists("java_mark_braces_in_parens_as_errors")
- syn match javaInParen contained "[{}]"
- hi def link javaInParen javaError
+ syn match javaInParen contained "[{}]"
+ hi def link javaInParen javaError
endif
+" Try not to fold top-level-type bodies under assumption that there is
+" but one such body.
+exec 'syn region javaBlock transparent start="\%(^\|^\S[^:]\+\)\@' . s:ff.Peek('120', '') . '<!{" end="}" fold'
+
" catch errors caused by wrong parenthesis
-syn region javaParenT transparent matchgroup=javaParen start="(" end=")" contains=@javaTop,javaParenT1
-syn region javaParenT1 transparent matchgroup=javaParen1 start="(" end=")" contains=@javaTop,javaParenT2 contained
-syn region javaParenT2 transparent matchgroup=javaParen2 start="(" end=")" contains=@javaTop,javaParenT contained
+syn region javaParenT transparent matchgroup=javaParen start="(" end=")" contains=@javaTop,javaInParen,javaParenT1
+syn region javaParenT1 transparent matchgroup=javaParen1 start="(" end=")" contains=@javaTop,javaInParen,javaParenT2 contained
+syn region javaParenT2 transparent matchgroup=javaParen2 start="(" end=")" contains=@javaTop,javaInParen,javaParenT contained
syn match javaParenError ")"
" catch errors caused by wrong square parenthesis
syn region javaParenT transparent matchgroup=javaParen start="\[" end="\]" contains=@javaTop,javaParenT1
@@ -445,7 +458,7 @@ endif
" The @javaTop cluster comprises non-contained Java syntax groups.
" Note that the syntax file "aidl.vim" relies on its availability.
-syn cluster javaTop contains=TOP,javaDocComment,javaFold,javaParenError,javaParenT
+syn cluster javaTop contains=TOP,javaDocComment,javaBlock,javaParenError,javaParenT
if !exists("java_minlines")
let java_minlines = 10
@@ -463,7 +476,6 @@ exec "syn sync ccomment javaComment minlines=" . java_minlines
hi def link javaLambdaDef Function
hi def link javaFuncDef Function
hi def link javaVarArg Function
-hi def link javaBraces Function
hi def link javaBranch Conditional
hi def link javaUserLabelRef javaUserLabel
hi def link javaLabel Label
@@ -533,4 +545,20 @@ let b:spell_options = "contained"
let &cpo = s:cpo_save
unlet s:module_info_cur_buf s:ff s:cpo_save
+" See ":help vim9-mix".
+if !has("vim9script")
+ finish
+endif
+
+def! s:JavaSyntaxFoldTextExpr(): string
+ return getline(v:foldstart) !~ '/\*\+\s*$'
+ ? foldtext()
+ : printf('+-%s%3d lines: ',
+ v:folddashes,
+ (v:foldend - v:foldstart + 1)) ..
+ getline(v:foldstart + 1)
+enddef
+
+setlocal foldtext=s:JavaSyntaxFoldTextExpr()
+delfunction! g:JavaSyntaxFoldTextExpr
" vim: sw=2 ts=8 noet sta
diff --git a/runtime/syntax/kdl.vim b/runtime/syntax/kdl.vim
index a36bb9e927..97e8f93b61 100644
--- a/runtime/syntax/kdl.vim
+++ b/runtime/syntax/kdl.vim
@@ -2,7 +2,7 @@
" Language: KDL
" Maintainer: Aram Drevekenin <aram@poor.dev>
" Maintainer: Yinzuo Jiang <jiangyinzuo@foxmail.com>
-" Latest Revision: 2024-06-10
+" Latest Revision: 2024-06-16
" quit when a syntax file was already loaded
if exists("b:current_syntax")
@@ -13,7 +13,8 @@ syn match kdlNode '\v(\w|-|\=)' display
syn match kdlBool '\v(true|false)' display
syn keyword kdlTodo contained TODO FIXME XXX NOTE
-syn match kdlComment "//.*$" contains=kdlTodo
+syn region kdlComment start="//" end="$" contains=kdlTodo,@Spell
+syn region kdlComment start="/\*" end="\*/" contains=kdlTodo,@Spell
" Regular int like number with - + or nothing in front
syn match kdlNumber '\d\+'
@@ -22,17 +23,17 @@ syn match kdlNumber '[-+]\d\+'
" Floating point number with decimal no E or e (+,-)
syn match kdlNumber '\d\+\.\d*' contained display
syn match kdlNumber '[-+]\d\+\.\d*' contained display
-
+
" Floating point like number with E and no decimal point (+,-)
syn match kdlNumber '[-+]\=\d[[:digit:]]*[eE][\-+]\=\d\+' contained display
syn match kdlNumber '\d[[:digit:]]*[eE][\-+]\=\d\+' contained display
-
+
" Floating point like number with E and decimal point (+,-)
syn match kdlNumber '[-+]\=\d[[:digit:]]*\.\d*[eE][\-+]\=\d\+' contained display
syn match kdlNumber '\d[[:digit:]]*\.\d*[eE][\-+]\=\d\+' contained display
syn region kdlString start='"' end='"' skip='\\\\\|\\"' display
-
+
syn region kdlChildren start="{" end="}" contains=kdlString,kdlNumber,kdlNode,kdlBool,kdlComment
hi def link kdlTodo Todo
@@ -43,3 +44,5 @@ hi def link kdlString String
hi def link kdlNumber Number
let b:current_syntax = "kdl"
+
+" vim: sw=2 sts=2 et
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c
index 1eb6402e6c..0a25b72451 100644
--- a/src/nvim/insexpand.c
+++ b/src/nvim/insexpand.c
@@ -3698,16 +3698,16 @@ static int find_next_completion_match(bool allow_get_expansion, int todo, bool a
while (--todo >= 0) {
if (compl_shows_dir_forward() && compl_shown_match->cp_next != NULL) {
- compl_shown_match = !compl_fuzzy_match ? compl_shown_match->cp_next
- : find_comp_when_fuzzy();
+ compl_shown_match = compl_fuzzy_match && compl_match_array != NULL
+ ? find_comp_when_fuzzy() : compl_shown_match->cp_next;
found_end = (compl_first_match != NULL
&& (is_first_match(compl_shown_match->cp_next)
|| is_first_match(compl_shown_match)));
} else if (compl_shows_dir_backward()
&& compl_shown_match->cp_prev != NULL) {
found_end = is_first_match(compl_shown_match);
- compl_shown_match = !compl_fuzzy_match ? compl_shown_match->cp_prev
- : find_comp_when_fuzzy();
+ compl_shown_match = compl_fuzzy_match && compl_match_array != NULL
+ ? find_comp_when_fuzzy() : compl_shown_match->cp_prev;
found_end |= is_first_match(compl_shown_match);
} else {
if (!allow_get_expansion) {
diff --git a/src/nvim/options.lua b/src/nvim/options.lua
index 9edb429cf8..efa2ea7dd9 100644
--- a/src/nvim/options.lua
+++ b/src/nvim/options.lua
@@ -4876,6 +4876,9 @@ return {
between tabs and spaces and for trailing blanks. Further changed by
the 'listchars' option.
+ When 'listchars' does not contain "tab" field, tabs are shown as "^I"
+ or "<09>", like how unprintable characters are displayed.
+
The cursor is displayed at the start of the space a Tab character
occupies, not at the end as usual in Normal mode. To get this cursor
position while displaying Tabs with spaces, use: >vim
diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c
index b8e7630802..6f8f858247 100644
--- a/src/nvim/popupmenu.c
+++ b/src/nvim/popupmenu.c
@@ -143,7 +143,7 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, i
|| (State == MODE_CMDLINE && ui_has(kUIWildmenu));
}
- pum_rl = (curwin->w_p_rl && State != MODE_CMDLINE);
+ pum_rl = State != MODE_CMDLINE && curwin->w_p_rl;
do {
// Mark the pum as visible already here,
@@ -450,7 +450,7 @@ static void pum_puts_with_attr(int col, char *text, hlf_T hlf)
}
char *rt_leader = NULL;
- if (curwin->w_p_rl) {
+ if (pum_rl) {
rt_leader = reverse_text(leader);
}
char *match_leader = rt_leader != NULL ? rt_leader : leader;
@@ -1212,12 +1212,14 @@ void pum_set_event_info(dict_T *dict)
static void pum_position_at_mouse(int min_width)
{
int min_row = 0;
+ int min_col = 0;
int max_row = Rows;
int max_col = Columns;
if (mouse_grid > 1) {
win_T *wp = get_win_by_grid_handle(mouse_grid);
if (wp != NULL) {
min_row = -wp->w_winrow;
+ min_col = -wp->w_wincol;
max_row = MAX(Rows - wp->w_winrow, wp->w_grid.rows);
max_col = MAX(Columns - wp->w_wincol, wp->w_grid.cols);
}
@@ -1230,6 +1232,7 @@ static void pum_position_at_mouse(int min_width)
} else {
pum_anchor_grid = mouse_grid;
}
+
if (max_row - mouse_row > pum_size) {
// Enough space below the mouse row.
pum_above = false;
@@ -1246,16 +1249,29 @@ static void pum_position_at_mouse(int min_width)
pum_row = min_row;
}
}
- if (max_col - mouse_col >= pum_base_width
- || max_col - mouse_col > min_width) {
- // Enough space to show at mouse column.
- pum_col = mouse_col;
+
+ if (pum_rl) {
+ if (mouse_col - min_col + 1 >= pum_base_width
+ || mouse_col - min_col + 1 > min_width) {
+ // Enough space to show at mouse column.
+ pum_col = mouse_col;
+ } else {
+ // Not enough space, left align with window.
+ pum_col = min_col + MIN(pum_base_width, min_width) - 1;
+ }
+ pum_width = pum_col - min_col + 1;
} else {
- // Not enough space, right align with window.
- pum_col = max_col - (pum_base_width > min_width ? min_width : pum_base_width);
+ if (max_col - mouse_col >= pum_base_width
+ || max_col - mouse_col > min_width) {
+ // Enough space to show at mouse column.
+ pum_col = mouse_col;
+ } else {
+ // Not enough space, right align with window.
+ pum_col = max_col - MIN(pum_base_width, min_width);
+ }
+ pum_width = max_col - pum_col;
}
- pum_width = max_col - pum_col;
if (pum_width > pum_base_width + 1) {
pum_width = pum_base_width + 1;
}
@@ -1337,6 +1353,7 @@ void pum_show_popupmenu(vimmenu_T *menu)
pum_compute_size();
pum_scrollbar = 0;
pum_height = pum_size;
+ pum_rl = curwin->w_p_rl;
pum_position_at_mouse(20);
pum_selected = -1;
@@ -1416,7 +1433,9 @@ void pum_make_popup(const char *path_name, int use_mouse_pos)
// Hack: set mouse position at the cursor so that the menu pops up
// around there.
mouse_row = curwin->w_grid.row_offset + curwin->w_wrow;
- mouse_col = curwin->w_grid.col_offset + curwin->w_wcol;
+ mouse_col = curwin->w_grid.col_offset
+ + (curwin->w_p_rl ? curwin->w_width_inner - curwin->w_wcol - 1
+ : curwin->w_wcol);
if (ui_has(kUIMultigrid)) {
mouse_grid = curwin->w_grid.target->handle;
} else if (curwin->w_grid.target != &default_grid) {
diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua
index 177b2d707a..76bef911ac 100644
--- a/test/functional/ui/popupmenu_spec.lua
+++ b/test/functional/ui/popupmenu_spec.lua
@@ -2530,6 +2530,7 @@ describe('builtin popupmenu', function()
]],
}
+ -- oldtest: Test_wildmenu_pum_rightleft()
feed('<tab>')
screen:expect {
grid = [[
@@ -4479,6 +4480,27 @@ describe('builtin popupmenu', function()
feed('<Esc>')
+ command('set rightleft')
+ feed('/X<CR>:popup PopUp<CR>')
+ screen:expect([[
+ evif ruof eerht owt eno|
+ evif ruof eerht{7:^X} owt eno dna|
+ {n: odnU }wt erom eno|
+ {1: }{n: }{1: ~}|
+ {1: }{n: etsaP }{1: ~}|
+ {1: }{n: }{1: ~}|
+ {1: }{n: droW tceleS }{1: ~}|
+ {1: }{n: ecnetneS tceleS }{1: ~}|
+ {1: }{n: hpargaraP tceleS }{1: ~}|
+ {1: }{n: eniL tceleS }{1: ~}|
+ {1: }{n: kcolB tceleS }{1: ~}|
+ {1: }{n: llA tceleS }{1: ~}|
+ {1: ~}|*7
+ :popup PopUp |
+ ]])
+ feed('<Esc>')
+ command('set norightleft')
+
-- Set an <expr> mapping to change a menu entry while it's displayed.
-- The text should not change but the command does.
-- Also verify that "changed" shows up, which means the mapping triggered.
@@ -4535,6 +4557,55 @@ describe('builtin popupmenu', function()
feed('<Esc>')
end)
+ -- oldtest: Test_mouse_popup_position()
+ it('position of right-click menu when clicking near edge', function()
+ screen:try_resize(50, 20)
+ exec([[
+ set mousemodel=popup_setpos
+ aunmenu *
+ source $VIMRUNTIME/menu.vim
+ call setline(1, join(range(20)))
+ ]])
+
+ api.nvim_input_mouse('right', 'press', '', 0, 0, 45 - 1)
+ screen:expect([[
+ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ^18 19 |
+ {1:~ }{n: Undo }|
+ {1:~ }{n: }|
+ {1:~ }{n: Paste }|
+ {1:~ }{n: }|
+ {1:~ }{n: Select Word }|
+ {1:~ }{n: Select Sentence }|
+ {1:~ }{n: Select Paragraph}|
+ {1:~ }{n: Select Line }|
+ {1:~ }{n: Select Block }|
+ {1:~ }{n: Select All }|
+ {1:~ }|*8
+ |
+ ]])
+ feed('<Esc>')
+
+ command('set rightleft')
+ api.nvim_input_mouse('right', 'press', '', 0, 0, 50 - 45)
+ screen:expect([[
+ 91 8^1 71 61 51 41 31 21 11 01 9 8 7 6 5 4 3 2 1 0|
+ {n: odnU }{1: ~}|
+ {n: }{1: ~}|
+ {n: etsaP }{1: ~}|
+ {n: }{1: ~}|
+ {n: droW tceleS }{1: ~}|
+ {n: ecnetneS tceleS }{1: ~}|
+ {n:hpargaraP tceleS }{1: ~}|
+ {n: eniL tceleS }{1: ~}|
+ {n: kcolB tceleS }{1: ~}|
+ {n: llA tceleS }{1: ~}|
+ {1: ~}|*8
+ |
+ ]])
+ feed('<Esc>')
+ command('set norightleft')
+ end)
+
describe('"kind" and "menu"', function()
before_each(function()
screen:try_resize(30, 8)
diff --git a/test/old/testdir/test_cmdline.vim b/test/old/testdir/test_cmdline.vim
index 443539fbfd..f83f782817 100644
--- a/test/old/testdir/test_cmdline.vim
+++ b/test/old/testdir/test_cmdline.vim
@@ -2905,6 +2905,24 @@ func Test_wildmenu_pum_odd_wildchar()
call StopVimInTerminal(buf)
endfunc
+" Test that 'rightleft' should not affect cmdline completion popup menu.
+func Test_wildmenu_pum_rightleft()
+ CheckFeature rightleft
+ CheckScreendump
+
+ let lines =<< trim END
+ set wildoptions=pum
+ set rightleft
+ END
+ call writefile(lines, 'Xwildmenu_pum_rl', 'D')
+ let buf = RunVimInTerminal('-S Xwildmenu_pum_rl', #{rows: 10, cols: 50})
+
+ call term_sendkeys(buf, ":sign \<Tab>")
+ call VerifyScreenDump(buf, 'Test_wildmenu_pum_rl', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
" Test for completion after a :substitute command followed by a pipe (|)
" character
func Test_cmdline_complete_substitute()
diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim
index 8bbda1dc99..ec9d88d3bf 100644
--- a/test/old/testdir/test_filetype.vim
+++ b/test/old/testdir/test_filetype.vim
@@ -992,6 +992,7 @@ func s:GetScriptChecks() abort
\ ['#!/path/regina']],
\ 'janet': [['#!/path/janet']],
\ 'dart': [['#!/path/dart']],
+ \ 'vim': [['#!/path/vim']],
\ }
endfunc
diff --git a/test/old/testdir/test_ins_complete.vim b/test/old/testdir/test_ins_complete.vim
index f8fed8d16c..0f974ebb5b 100644
--- a/test/old/testdir/test_ins_complete.vim
+++ b/test/old/testdir/test_ins_complete.vim
@@ -2634,6 +2634,19 @@ func Test_complete_fuzzy_match()
call feedkeys("S\<C-x>\<C-o>fb\<C-n>", 'tx')
call assert_equal('fooBaz', g:word)
+ " avoid breaking default completion behavior
+ set completeopt=fuzzy,menu
+ call setline(1, ['hello help hero h'])
+ " Use "!" flag of feedkeys() so that ex_normal_busy is not set and
+ " ins_compl_check_keys() is not skipped.
+ " Add a "0" after the <Esc> to avoid waiting for an escape sequence.
+ call feedkeys("A\<C-X>\<C-N>\<Esc>0", 'tx!')
+ call assert_equal('hello help hero hello', getline('.'))
+ set completeopt+=noinsert
+ call setline(1, ['hello help hero h'])
+ call feedkeys("A\<C-X>\<C-N>\<Esc>0", 'tx!')
+ call assert_equal('hello help hero h', getline('.'))
+
" clean up
set omnifunc=
bw!
diff --git a/test/old/testdir/test_popup.vim b/test/old/testdir/test_popup.vim
index e370484b28..b6b8b44f82 100644
--- a/test/old/testdir/test_popup.vim
+++ b/test/old/testdir/test_popup.vim
@@ -910,6 +910,13 @@ func Test_popup_command_dump()
call term_sendkeys(buf, "\<Esc>")
+ if has('rightleft')
+ call term_sendkeys(buf, ":set rightleft\<CR>")
+ call term_sendkeys(buf, "/X\<CR>:popup PopUp\<CR>")
+ call VerifyScreenDump(buf, 'Test_popup_command_rl', {})
+ call term_sendkeys(buf, "\<Esc>:set norightleft\<CR>")
+ endif
+
" Set a timer to change a menu entry while it's displayed. The text should
" not change but the command does. Making the screendump also verifies that
" "changed" shows up, which means the timer triggered.
@@ -932,6 +939,37 @@ func Test_popup_command_dump()
call StopVimInTerminal(buf)
endfunc
+" Test position of right-click menu when clicking near window edge.
+func Test_mouse_popup_position()
+ CheckFeature menu
+ CheckScreendump
+
+ let script =<< trim END
+ set mousemodel=popup_setpos
+ source $VIMRUNTIME/menu.vim
+ call setline(1, join(range(20)))
+ func Trigger(col)
+ call test_setmouse(1, a:col)
+ call feedkeys("\<RightMouse>", 't')
+ endfunc
+ END
+ call writefile(script, 'XmousePopupPosition', 'D')
+ let buf = RunVimInTerminal('-S XmousePopupPosition', #{rows: 20, cols: 50})
+
+ call term_sendkeys(buf, ":call Trigger(45)\<CR>")
+ call VerifyScreenDump(buf, 'Test_mouse_popup_position_01', {})
+ call term_sendkeys(buf, "\<Esc>")
+
+ if has('rightleft')
+ call term_sendkeys(buf, ":set rightleft\<CR>")
+ call term_sendkeys(buf, ":call Trigger(50 + 1 - 45)\<CR>")
+ call VerifyScreenDump(buf, 'Test_mouse_popup_position_02', {})
+ call term_sendkeys(buf, "\<Esc>:set norightleft\<CR>")
+ endif
+
+ call StopVimInTerminal(buf)
+endfunc
+
func Test_popup_complete_backwards()
new
call setline(1, ['Post', 'Port', 'Po'])