aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-07-13 07:02:06 +0800
committerGitHub <noreply@github.com>2023-07-13 07:02:06 +0800
commit9359701eae7bd8a59e4a916e085cc686f609d693 (patch)
tree0ff0b5298b95f43ac14ab55779591d3bbec0e2b4
parent317c80f460a7826421f40f57ee8bdbd736b0f225 (diff)
downloadrneovim-9359701eae7bd8a59e4a916e085cc686f609d693.tar.gz
rneovim-9359701eae7bd8a59e4a916e085cc686f609d693.tar.bz2
rneovim-9359701eae7bd8a59e4a916e085cc686f609d693.zip
test(extmarks): add test for virt_text_win_col with cpo+=n (#24328)
-rw-r--r--runtime/doc/api.txt7
-rw-r--r--src/nvim/api/extmark.c7
-rw-r--r--test/functional/ui/decorations_spec.lua42
3 files changed, 48 insertions, 8 deletions
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index d128bf0221..a20ba9a348 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -2615,15 +2615,16 @@ nvim_buf_set_extmark({buffer}, {ns_id}, {line}, {col}, {*opts})
string or as an integer, the latter which can be obtained
using |nvim_get_hl_id_by_name()|.
• virt_text_pos : position of virtual text. Possible values:
- • "eol": right after eol character (default)
+ • "eol": right after eol character (default).
• "overlay": display over the specified column, without
shifting the underlying text.
• "right_align": display right aligned in the window.
• "inline": display at the specified column, and shift the
- buffer text to the right as needed
+ buffer text to the right as needed.
• virt_text_win_col : position the virtual text at a fixed
- window column (starting from the first text column)
+ window column (starting from the first text column of the
+ screen line) instead of "virt_text_pos".
• virt_text_hide : hide the virtual text when the background
text is selected or hidden because of scrolling with
'nowrap' or 'smoothscroll'. Currently only affects
diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c
index 0608a8961d..d254373eb0 100644
--- a/src/nvim/api/extmark.c
+++ b/src/nvim/api/extmark.c
@@ -473,15 +473,16 @@ Array nvim_buf_get_extmarks(Buffer buffer, Integer ns_id, Object start, Object e
/// either as a string or as an integer, the latter which
/// can be obtained using |nvim_get_hl_id_by_name()|.
/// - virt_text_pos : position of virtual text. Possible values:
-/// - "eol": right after eol character (default)
+/// - "eol": right after eol character (default).
/// - "overlay": display over the specified column, without
/// shifting the underlying text.
/// - "right_align": display right aligned in the window.
/// - "inline": display at the specified column, and
-/// shift the buffer text to the right as needed
+/// shift the buffer text to the right as needed.
/// - virt_text_win_col : position the virtual text at a fixed
/// window column (starting from the first
-/// text column)
+/// text column of the screen line) instead
+/// of "virt_text_pos".
/// - virt_text_hide : hide the virtual text when the background
/// text is selected or hidden because of
/// scrolling with 'nowrap' or 'smoothscroll'.
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua
index 5eb9f9bc0a..b526aa86c8 100644
--- a/test/functional/ui/decorations_spec.lua
+++ b/test/functional/ui/decorations_spec.lua
@@ -1130,7 +1130,45 @@ describe('extmark decorations', function()
|
]]}
- command 'set nowrap'
+ command 'set number'
+ screen:expect{grid=[[
+ {2: 1 }for _,item in ipairs(items) do |
+ {2: 2 } local text, hl_id_cell, cou{4:Very} unpack{4:VERY}|
+ {2: }m) |
+ {2: 3 } if |
+ {2: 4 }hl_id_cell ~= nil then {4:Much} {4:MUCH}|
+ {2: 5 } --^ -- -- -- -- -- -- -- -- -- -- -- hl|
+ {2: }_id = hl_id_cell {4:Error} {4:ERROR}|
+ {2: 6 } end |
+ {2: 7 } for _ = 1, (count or 1) do |
+ {2: 8 } local cell = line[colpos] |
+ {2: 9 } {1:-} cell.text = text {1:-}|
+ {2: 10 } cell.hl_id = hl_id |
+ {2: 11 } colpos = colpos+1 |
+ {2: 12 } end |
+ |
+ ]]}
+
+ command 'set cpoptions+=n'
+ screen:expect{grid=[[
+ {2: 1 }for _,item in ipairs(items) do |
+ {2: 2 } local text, hl_id_cell, cou{4:Very} unpack{4:VERY}|
+ m) |
+ {2: 3 } if |
+ {2: 4 }hl_id_cell ~= nil then {4:Much} {4:MUCH}|
+ {2: 5 } --^ -- -- -- -- -- -- -- -- -- -- -- hl|
+ _id = hl_id_cell {4:Error} {4:ERROR}|
+ {2: 6 } end |
+ {2: 7 } for _ = 1, (count or 1) do |
+ {2: 8 } local cell = line[colpos] |
+ {2: 9 } {1:-} cell.text = text {1:-}|
+ {2: 10 } cell.hl_id = hl_id |
+ {2: 11 } colpos = colpos+1 |
+ {2: 12 } end |
+ |
+ ]]}
+
+ command 'set cpoptions-=n nonumber nowrap'
screen:expect{grid=[[
for _,item in ipairs(items) do |
local text, hl_id_cell, cou{4:Very} unpack(ite{4:VERY}|
@@ -1149,7 +1187,7 @@ describe('extmark decorations', function()
|
]]}
- feed('8zl')
+ feed '8zl'
screen:expect{grid=[[
em in ipairs(items) do |
l text, hl_id_cell, count = unp{4:Very}item) {4:VERY}|