aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/options.txt43
-rw-r--r--runtime/doc/vim_diff.txt1
-rw-r--r--src/nvim/options.lua4
-rw-r--r--src/nvim/quickfix.c16
-rw-r--r--src/nvim/testdir/shared.vim20
-rw-r--r--src/nvim/testdir/test_popup.vim12
-rw-r--r--src/nvim/testdir/test_quickfix.vim27
-rw-r--r--src/nvim/testdir/test_quotestar.vim12
-rw-r--r--test/functional/terminal/helpers.lua2
-rw-r--r--test/functional/terminal/tui_spec.lua6
-rw-r--r--test/functional/ui/embed_spec.lua3
-rw-r--r--test/functional/ui/output_spec.lua7
-rw-r--r--test/functional/ui/screen.lua5
13 files changed, 100 insertions, 58 deletions
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index d1e84c5aec..29d9a60aa2 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -703,47 +703,24 @@ A jump table for the options with a short description can be found at |Q_op|.
been set.
*'background'* *'bg'*
-'background' 'bg' string (default "dark" or "light", see below)
- global
- When set to "dark", Vim will try to use colors that look good on a
- dark background. When set to "light", Vim will try to use colors that
- look good on a light background. Any other value is illegal.
- Vim tries to set the default value according to the terminal used.
- This will not always be correct.
- Setting this option does not change the background color, it tells Vim
- what the background color looks like. For changing the background
- color, see |:hi-normal|.
-
- When 'background' is set Vim will adjust the default color groups for
- the new value. But the colors used for syntax highlighting will not
- change. *g:colors_name*
+'background' 'bg' string (default "dark")
+ global
+ When set to "dark" or "light", Nvim will adjust the default color
+ groups for a dark or light background, respectively.
+
+ This option does NOT change the background color, it tells Nvim what
+ the "inherited" (terminal/GUI) background looks like.
+ See |:hi-normal| if you want to set the background color explicitly.
+ *g:colors_name*
When a color scheme is loaded (the "g:colors_name" variable is set)
setting 'background' will cause the color scheme to be reloaded. If
the color scheme adjusts to the value of 'background' this will work.
However, if the color scheme sets 'background' itself the effect may
be undone. First delete the "g:colors_name" variable when needed.
- When setting 'background' to the default value with: >
- :set background&
-< Vim will guess the value. In the GUI this should work correctly,
- in other cases Vim might not be able to guess the right value.
-
- When starting the GUI, the default value for 'background' will be
- "light". When the value is not set in the gvimrc, and Vim detects
- that the background is actually quite dark, 'background' is set to
- "dark". But this happens only AFTER the gvimrc file has been read
- (because the window needs to be opened to find the actual background
- color). To get around this, force the GUI window to be opened by
- putting a ":gui" command in the gvimrc file, before where the value
- of 'background' is used (e.g., before ":syntax on").
-
- For Windows the default is "dark". "dark" should be used if $COLORFGBG
- suggests a dark background (not yet implemented). Otherwise the default
- is "light".
-
Normally this option would be set in the vimrc file. Possibly
depending on the terminal name. Example: >
- :if $TERM == "xterm"
+ :if $TERM ==# "xterm"
: set background=dark
:endif
< When this option is set, the default settings for the highlight groups
diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt
index 4fbfb0d7a0..3915763eed 100644
--- a/runtime/doc/vim_diff.txt
+++ b/runtime/doc/vim_diff.txt
@@ -27,6 +27,7 @@ a complete and centralized reference of those differences.
- 'autoindent' is set by default
- 'autoread' is set by default
+- 'background' always defaults to "dark"
- 'backspace' defaults to "indent,eol,start"
- 'backupdir' defaults to .,~/.local/share/nvim/backup (|xdg|)
- 'belloff' defaults to "all"
diff --git a/src/nvim/options.lua b/src/nvim/options.lua
index bc7f1a2b0a..b0575df7ec 100644
--- a/src/nvim/options.lua
+++ b/src/nvim/options.lua
@@ -132,10 +132,10 @@ return {
{
full_name='background', abbreviation='bg',
type='string', scope={'global'},
- vi_def=true,
+ vim=true,
redraw={'all_windows'},
varname='p_bg',
- defaults={if_true={vi="light"}}
+ defaults={if_true={vi="light",vim="dark"}}
},
{
full_name='backspace', abbreviation='bs',
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index 51a7dd670f..d9e307bb71 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -2661,6 +2661,8 @@ void ex_copen(exarg_T *eap)
}
}
} else {
+ int flags = 0;
+
qf_buf = qf_find_buf(qi);
/* The current window becomes the previous window afterwards. */
@@ -2668,11 +2670,17 @@ void ex_copen(exarg_T *eap)
if ((eap->cmdidx == CMD_copen || eap->cmdidx == CMD_cwindow)
&& cmdmod.split == 0)
- /* Create the new window at the very bottom, except when
- * :belowright or :aboveleft is used. */
+ // Create the new quickfix window at the very bottom, except when
+ // :belowright or :aboveleft is used.
win_goto(lastwin);
- if (win_split(height, WSP_BELOW | WSP_NEWLOC) == FAIL)
- return; /* not enough room for window */
+ // Default is to open the window below the current window
+ if (cmdmod.split == 0) {
+ flags = WSP_BELOW;
+ }
+ flags |= WSP_NEWLOC;
+ if (win_split(height, flags) == FAIL) {
+ return; // not enough room for window
+ }
RESET_BINDING(curwin);
if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow) {
diff --git a/src/nvim/testdir/shared.vim b/src/nvim/testdir/shared.vim
index b1f1d8fe66..eb6798f353 100644
--- a/src/nvim/testdir/shared.vim
+++ b/src/nvim/testdir/shared.vim
@@ -136,29 +136,27 @@ endfunc
" Wait for up to a second for "expr" to become true.
" Return time slept in milliseconds. With the +reltime feature this can be
" more than the actual waiting time. Without +reltime it can also be less.
-func WaitFor(expr)
+func WaitFor(expr, ...)
+ let timeout = get(a:000, 0, 1000)
" using reltime() is more accurate, but not always available
if has('reltime')
let start = reltime()
else
let slept = 0
endif
- for i in range(100)
- try
- if eval(a:expr)
- if has('reltime')
- return float2nr(reltimefloat(reltime(start)) * 1000)
- endif
- return slept
+ for i in range(timeout / 10)
+ if eval(a:expr)
+ if has('reltime')
+ return float2nr(reltimefloat(reltime(start)) * 1000)
endif
- catch
- endtry
+ return slept
+ endif
if !has('reltime')
let slept += 10
endif
sleep 10m
endfor
- return 1000
+ return timeout
endfunc
" Wait for up to a given milliseconds.
diff --git a/src/nvim/testdir/test_popup.vim b/src/nvim/testdir/test_popup.vim
index 6fd58a1483..c9cd04018c 100644
--- a/src/nvim/testdir/test_popup.vim
+++ b/src/nvim/testdir/test_popup.vim
@@ -678,18 +678,24 @@ func Test_popup_and_window_resize()
let g:buf = term_start([$NVIM_PRG, '--clean', '-c', 'set noswapfile'], {'term_rows': h / 3})
call term_sendkeys(g:buf, (h / 3 - 1)."o\<esc>G")
call term_sendkeys(g:buf, "i\<c-x>")
- call term_wait(g:buf, 100)
+ call term_wait(g:buf, 200)
call term_sendkeys(g:buf, "\<c-v>")
call term_wait(g:buf, 100)
+ " popup first entry "!" must be at the top
+ call WaitFor('term_getline(g:buf, 1) =~ "^!"')
call assert_match('^!\s*$', term_getline(g:buf, 1))
exe 'resize +' . (h - 1)
call term_wait(g:buf, 100)
redraw!
- call WaitFor('"" == term_getline(g:buf, 1)')
+ " popup shifted down, first line is now empty
+ call WaitFor('term_getline(g:buf, 1) == ""')
call assert_equal('', term_getline(g:buf, 1))
sleep 100m
- call WaitFor('"^!" =~ term_getline(g:buf, term_getcursor(g:buf)[0] + 1)')
+ " popup is below cursor line and shows first match "!"
+ call WaitFor('term_getline(g:buf, term_getcursor(g:buf)[0] + 1) =~ "^!"')
call assert_match('^!\s*$', term_getline(g:buf, term_getcursor(g:buf)[0] + 1))
+ " cursor line also shows !
+ call assert_match('^!\s*$', term_getline(g:buf, term_getcursor(g:buf)[0]))
bwipe!
endfunc
diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim
index bfe5791ec8..cb3e7ca8f6 100644
--- a/src/nvim/testdir/test_quickfix.vim
+++ b/src/nvim/testdir/test_quickfix.vim
@@ -2637,3 +2637,30 @@ func Test_shorten_fname()
silent! clist
call assert_equal('test_quickfix.vim', bufname('test_quickfix.vim'))
endfunc
+
+" Test for the position of the quickfix and location list window
+func Test_qfwin_pos()
+ " Open two windows
+ new | only
+ new
+ cexpr ['F1:10:L10']
+ copen
+ " Quickfix window should be the bottom most window
+ call assert_equal(3, winnr())
+ close
+ " Open at the very top
+ wincmd t
+ topleft copen
+ call assert_equal(1, winnr())
+ close
+ " open left of the current window
+ wincmd t
+ below new
+ leftabove copen
+ call assert_equal(2, winnr())
+ close
+ " open right of the current window
+ rightbelow copen
+ call assert_equal(3, winnr())
+ close
+endfunc
diff --git a/src/nvim/testdir/test_quotestar.vim b/src/nvim/testdir/test_quotestar.vim
index 3a7edcbd7c..3ce1a84281 100644
--- a/src/nvim/testdir/test_quotestar.vim
+++ b/src/nvim/testdir/test_quotestar.vim
@@ -87,6 +87,18 @@ func Do_test_quotestar_for_x11()
" Check that the *-register of this vim instance is changed as expected.
call WaitFor('@* == "yes"', 3000)
+ " Handle the large selection over 262040 byte.
+ let length = 262044
+ let sample = 'a' . repeat('b', length - 2) . 'c'
+ let @* = sample
+ call WaitFor('remote_expr("' . name . '", "len(@*) >= ' . length . '", "", 1)', 3000)
+ let res = remote_expr(name, "@*", "", 2)
+ call assert_equal(length, len(res))
+ " Check length to prevent a large amount of output at assertion failure.
+ if length == len(res)
+ call assert_equal(sample, res)
+ endif
+
if has('unix') && has('gui') && !has('gui_running')
let @* = ''
diff --git a/test/functional/terminal/helpers.lua b/test/functional/terminal/helpers.lua
index bd24b9785d..ae8d4704e4 100644
--- a/test/functional/terminal/helpers.lua
+++ b/test/functional/terminal/helpers.lua
@@ -52,7 +52,7 @@ local function screen_setup(extra_rows, command, cols)
[7] = {foreground = 130},
[8] = {foreground = 15, background = 1}, -- error message
[9] = {foreground = 4},
- [10] = {foreground = 2}, -- "Press ENTER" in embedded :terminal session.
+ [10] = {foreground = 121}, -- "Press ENTER" in embedded :terminal session.
})
screen:attach({rgb=false})
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index 365bd2a0be..a47fed0442 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -134,15 +134,17 @@ describe('tui', function()
feed_data('\022\007') -- ctrl+g
feed_data('\022\022') -- ctrl+v
feed_data('\022\013') -- ctrl+m
+ local attrs = screen:get_default_attr_ids()
+ attrs[11] = {foreground = 81}
screen:expect([[
- {9:^G^V^M}{1: } |
+ {11:^G^V^M}{1: } |
{4:~ }|
{4:~ }|
{4:~ }|
{5:[No Name] [+] }|
{3:-- INSERT --} |
{3:-- TERMINAL --} |
- ]])
+ ]], attrs)
end)
it('automatically sends <Paste> for bracketed paste sequences', function()
diff --git a/test/functional/ui/embed_spec.lua b/test/functional/ui/embed_spec.lua
index 4fc93c3b63..a7f5cc2bfa 100644
--- a/test/functional/ui/embed_spec.lua
+++ b/test/functional/ui/embed_spec.lua
@@ -17,6 +17,7 @@ local function test_embed(ext_linegrid)
[1] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
[2] = {bold = true, foreground = Screen.colors.SeaGreen4},
[3] = {bold = true, foreground = Screen.colors.Blue1},
+ [4] = {bold = true, foreground = Screen.colors.Green},
})
end
@@ -56,7 +57,7 @@ local function test_embed(ext_linegrid)
Error detected while processing pre-vimrc command line: |
foo |
{1:bar} |
- {2:Press ENTER or type command to continue}^ |
+ {4:Press ENTER or type command to continue}^ |
]])
end)
diff --git a/test/functional/ui/output_spec.lua b/test/functional/ui/output_spec.lua
index 1850d436ac..aa99499ec6 100644
--- a/test/functional/ui/output_spec.lua
+++ b/test/functional/ui/output_spec.lua
@@ -68,7 +68,12 @@ describe("shell command :!", function()
|
{10:Press ENTER or type command to continue}{1: } |
{3:-- TERMINAL --} |
- ]])
+ ]], {
+ -- test/functional/helpers.lua defaults to background=light.
+ [1] = {reverse = true},
+ [3] = {bold = true},
+ [10] = {foreground = 2},
+ })
end)
end)
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua
index af036913d8..e5b522e775 100644
--- a/test/functional/ui/screen.lua
+++ b/test/functional/ui/screen.lua
@@ -72,6 +72,7 @@
-- To debug screen tests, see Screen:redraw_debug().
local global_helpers = require('test.helpers')
+local deepcopy = global_helpers.deepcopy
local shallowcopy = global_helpers.shallowcopy
local helpers = require('test.functional.helpers')(nil)
local request, run, uimeths = helpers.request, helpers.run, helpers.uimeths
@@ -176,6 +177,10 @@ function Screen:set_default_attr_ids(attr_ids)
self._default_attr_ids = attr_ids
end
+function Screen:get_default_attr_ids()
+ return deepcopy(self._default_attr_ids)
+end
+
function Screen:set_default_attr_ignore(attr_ignore)
self._default_attr_ignore = attr_ignore
end