aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/filetype.vim6
-rw-r--r--src/nvim/buffer.c3
-rw-r--r--src/nvim/screen.c7
-rw-r--r--src/nvim/testdir/check.vim11
-rw-r--r--src/nvim/testdir/test_filetype.vim2
-rw-r--r--src/nvim/testdir/test_swap.vim12
-rw-r--r--src/nvim/testdir/test_visual.vim21
7 files changed, 60 insertions, 2 deletions
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 2617d8ffc0..40d7e8be08 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -646,6 +646,9 @@ au BufNewFile,BufRead *.mo,*.gdmo setf gdmo
" Gedcom
au BufNewFile,BufRead *.ged,lltxxxxx.txt setf gedcom
+" Gemtext
+au BufNewFile,BufRead *.gmi,*.gemini setf gemtext
+
" Gift (Moodle)
autocmd BufRead,BufNewFile *.gift setf gift
@@ -864,6 +867,9 @@ au BufNewFile,BufRead *.json-patch setf json
" Jupyter Notebook is also json
au BufNewFile,BufRead *.ipynb setf json
+" JSONC
+au BufNewFile,BufRead *.jsonc setf jsonc
+
" Kixtart
au BufNewFile,BufRead *.kix setf kix
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index f1f32076bf..8decd02b3a 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -901,7 +901,10 @@ void handle_swap_exists(bufref_T *old_curbuf)
if (old_curbuf == NULL
|| !bufref_valid(old_curbuf)
|| old_curbuf->br_buf == curbuf) {
+ // Block autocommands here because curwin->w_buffer is NULL.
+ block_autocmds();
buf = buflist_new(NULL, NULL, 1L, BLN_CURBUF | BLN_LISTED);
+ unblock_autocmds();
} else {
buf = old_curbuf->br_buf;
}
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 3446a944cd..cab41d1783 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -1186,9 +1186,12 @@ static void win_update(win_T *wp, Providers *providers)
getvcols(wp, &VIsual, &curwin->w_cursor, &fromc, &toc);
ve_flags = save_ve_flags;
- ++toc;
- if (curwin->w_curswant == MAXCOL)
+ toc++;
+ // Highlight to the end of the line, unless 'virtualedit' has
+ // "block".
+ if (curwin->w_curswant == MAXCOL && !(ve_flags & VE_BLOCK)) {
toc = MAXCOL;
+ }
if (fromc != wp->w_old_cursor_fcol
|| toc != wp->w_old_cursor_lcol) {
diff --git a/src/nvim/testdir/check.vim b/src/nvim/testdir/check.vim
index 7b06e53dd5..14bab33a2f 100644
--- a/src/nvim/testdir/check.vim
+++ b/src/nvim/testdir/check.vim
@@ -9,6 +9,17 @@ func CheckFeature(name)
endif
endfunc
+" Command to check for the absence of a feature.
+command -nargs=1 CheckNotFeature call CheckNotFeature(<f-args>)
+func CheckNotFeature(name)
+ if !has(a:name, 1)
+ throw 'Checking for non-existent feature ' .. a:name
+ endif
+ if has(a:name)
+ throw 'Skipped: ' .. a:name .. ' feature present'
+ endif
+endfunc
+
" Command to check for the presence of a working option.
command -nargs=1 CheckOption call CheckOption(<f-args>)
func CheckOption(name)
diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim
index eb6151fbe1..18b810e63f 100644
--- a/src/nvim/testdir/test_filetype.vim
+++ b/src/nvim/testdir/test_filetype.vim
@@ -192,6 +192,7 @@ let s:filename_checks = {
\ 'gdb': ['.gdbinit'],
\ 'gdmo': ['file.mo', 'file.gdmo'],
\ 'gedcom': ['file.ged', 'lltxxxxx.txt', '/tmp/lltmp', '/tmp/lltmp-file', 'any/tmp/lltmp', 'any/tmp/lltmp-file'],
+ \ 'gemtext': ['file.gmi', 'file.gemini'],
\ 'gift': ['file.gift'],
\ 'gitcommit': ['COMMIT_EDITMSG', 'MERGE_MSG', 'TAG_EDITMSG'],
\ 'gitconfig': ['file.git/config', '.gitconfig', '.gitmodules', 'file.git/modules//config', '/.config/git/config', '/etc/gitconfig', '/etc/gitconfig.d/file', '/.gitconfig.d/file', 'any/.config/git/config', 'any/.gitconfig.d/file', 'some.git/config', 'some.git/modules/any/config'],
@@ -260,6 +261,7 @@ let s:filename_checks = {
\ 'jovial': ['file.jov', 'file.j73', 'file.jovial'],
\ 'jproperties': ['file.properties', 'file.properties_xx', 'file.properties_xx_xx', 'some.properties_xx_xx_file'],
\ 'json': ['file.json', 'file.jsonp', 'file.json-patch', 'file.webmanifest', 'Pipfile.lock', 'file.ipynb'],
+ \ 'jsonc': ['file.jsonc'],
\ 'jsp': ['file.jsp'],
\ 'kconfig': ['Kconfig', 'Kconfig.debug', 'Kconfig.file'],
\ 'kivy': ['file.kv'],
diff --git a/src/nvim/testdir/test_swap.vim b/src/nvim/testdir/test_swap.vim
index f27920d20f..3c191cd7c7 100644
--- a/src/nvim/testdir/test_swap.vim
+++ b/src/nvim/testdir/test_swap.vim
@@ -319,6 +319,7 @@ func Test_swap_prompt_splitwin()
let buf = RunVimInTerminal('', {'rows': 20})
call term_sendkeys(buf, ":set nomore\n")
call term_sendkeys(buf, ":set noruler\n")
+
call term_sendkeys(buf, ":split Xfile1\n")
call term_wait(buf)
call WaitForAssert({-> assert_match('^\[O\]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort: $', term_getline(buf, 20))})
@@ -330,8 +331,19 @@ func Test_swap_prompt_splitwin()
call term_wait(buf)
call WaitForAssert({-> assert_match('^1$', term_getline(buf, 20))})
call StopVimInTerminal(buf)
+
+ " This caused Vim to crash when typing "q".
+ " TODO: it does not actually reproduce the crash.
+ call writefile(['au BufAdd * set virtualedit=all'], 'Xvimrc')
+
+ let buf = RunVimInTerminal('-u Xvimrc Xfile1', {'rows': 20, 'wait_for_ruler': 0})
+ call TermWait(buf)
+ call WaitForAssert({-> assert_match('^\[O\]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:', term_getline(buf, 20))})
+ call term_sendkeys(buf, "q")
+
%bwipe!
call delete('Xfile1')
+ call delete('Xvimrc')
endfunc
func Test_swap_symlink()
diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim
index b7c5717bd2..9c62bdb16e 100644
--- a/src/nvim/testdir/test_visual.vim
+++ b/src/nvim/testdir/test_visual.vim
@@ -2,6 +2,7 @@
source shared.vim
source check.vim
+source screendump.vim
func Test_block_shift_multibyte()
" Uses double-wide character.
@@ -1082,5 +1083,25 @@ func Test_visual_put_blockedit_zy_and_zp()
bw!
endfunc
+func Test_visual_block_with_virtualedit()
+ CheckScreendump
+
+ let lines =<< trim END
+ call setline(1, ['aaaaaa', 'bbbb', 'cc'])
+ set virtualedit=block
+ normal G
+ END
+ call writefile(lines, 'XTest_block')
+
+ let buf = RunVimInTerminal('-S XTest_block', {'rows': 8, 'cols': 50})
+ call term_sendkeys(buf, "\<C-V>gg$")
+ call VerifyScreenDump(buf, 'Test_visual_block_with_virtualedit', {})
+
+ " clean up
+ call term_sendkeys(buf, "\<Esc>")
+ call StopVimInTerminal(buf)
+ call delete('XTest_beval')
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab