Skip to content

Commit 7ecb98a

Browse files
committed
vim-patch:8.1.2172: spell highlight is wrong at start of the line
Problem: Spell highlight is wrong at start of the line. Solution: Fix setting the "v" variable. (closes vim/vim#5078) vim/vim@7751d1d Skip spell tests in OpenBSD. Nvim or screen likely crashed. Revist once issue neovim#12104 is fixed. Skip the test for the following reasons: - unknown regression caused by neovim#12104 - cannot revert failing test from neovim@ed0d135
1 parent f1e5817 commit 7ecb98a

File tree

4 files changed

+81
-3
lines changed

4 files changed

+81
-3
lines changed

src/nvim/screen.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3476,6 +3476,7 @@ win_line (
34763476
* Only do this when there is no syntax highlighting, the
34773477
* @Spell cluster is not used or the current syntax item
34783478
* contains the @Spell cluster. */
3479+
v = (long)(ptr - line);
34793480
if (has_spell && v >= word_end && v > cur_checked_col) {
34803481
spell_attr = 0;
34813482
if (!attr_pri) {

src/nvim/testdir/check.vim

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
source shared.vim
2+
source term_util.vim
3+
4+
" Command to check that making screendumps is supported.
5+
" Caller must source screendump.vim
6+
command CheckScreendump call CheckScreendump()
7+
func CheckScreendump()
8+
if !CanRunVimInTerminal()
9+
throw 'Skipped: cannot make screendumps'
10+
endif
11+
endfunc

src/nvim/testdir/test_spell.vim

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
" Test spell checking
22
" Note: this file uses latin1 encoding, but is used with utf-8 encoding.
33

4+
source check.vim
45
if !has('spell')
56
finish
67
endif
78

9+
source screendump.vim
10+
811
func TearDown()
912
set nospell
1013
call delete('Xtest.aff')
@@ -477,6 +480,44 @@ func RunGoodBad(good, bad, expected_words, expected_bad_words)
477480
bwipe!
478481
endfunc
479482

483+
func Test_spell_screendump()
484+
CheckScreendump
485+
486+
let lines =<< trim END
487+
call setline(1, [
488+
\ "This is some text without any spell errors. Everything",
489+
\ "should just be black, nothing wrong here.",
490+
\ "",
491+
\ "This line has a sepll error. and missing caps.",
492+
\ "And and this is the the duplication.",
493+
\ "with missing caps here.",
494+
\ ])
495+
set spell spelllang=en_nz
496+
END
497+
call writefile(lines, 'XtestSpell')
498+
let buf = RunVimInTerminal('-S XtestSpell', {'rows': 8})
499+
call VerifyScreenDump(buf, 'Test_spell_1', {})
500+
501+
let lines =<< trim END
502+
call setline(1, [
503+
\ "This is some text without any spell errors. Everything",
504+
\ "should just be black, nothing wrong here.",
505+
\ "",
506+
\ "This line has a sepll error. and missing caps.",
507+
\ "And and this is the the duplication.",
508+
\ "with missing caps here.",
509+
\ ])
510+
set spell spelllang=en_nz
511+
END
512+
call writefile(lines, 'XtestSpell')
513+
let buf = RunVimInTerminal('-S XtestSpell', {'rows': 8})
514+
call VerifyScreenDump(buf, 'Test_spell_1', {})
515+
516+
" clean up
517+
call StopVimInTerminal(buf)
518+
call delete('XtestSpell')
519+
endfunc
520+
480521
let g:test_data_aff1 = [
481522
\"SET ISO8859-1",
482523
\"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ",

test/functional/ui/spell_spec.lua

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ local helpers = require('test.functional.helpers')(after_each)
44
local Screen = require('test.functional.ui.screen')
55
local clear = helpers.clear
66
local feed = helpers.feed
7-
local feed_command = helpers.feed_command
87
local insert = helpers.insert
8+
local uname = helpers.uname
9+
local command = helpers.command
910

1011
describe("'spell'", function()
1112
local screen
@@ -16,12 +17,14 @@ describe("'spell'", function()
1617
screen:attach()
1718
screen:set_default_attr_ids( {
1819
[0] = {bold=true, foreground=Screen.colors.Blue},
19-
[1] = {special = Screen.colors.Red, undercurl = true}
20+
[1] = {special = Screen.colors.Red, undercurl = true},
21+
[2] = {special = Screen.colors.Blue1, undercurl = true},
2022
})
2123
end)
2224

2325
it('joins long lines #7937', function()
24-
feed_command('set spell')
26+
if uname() == 'openbsd' then pending('FIXME #12104', function() end) return end
27+
command('set spell')
2528
insert([[
2629
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
2730
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
@@ -42,4 +45,26 @@ describe("'spell'", function()
4245
|
4346
]])
4447
end)
48+
49+
it('has correct highlight at start of line', function()
50+
insert([[
51+
"This is some text without any spell errors. Everything",
52+
"should just be black, nothing wrong here.",
53+
"",
54+
"This line has a sepll error. and missing caps.",
55+
"And and this is the the duplication.",
56+
"with missing caps here.",
57+
]])
58+
command('set spell spelllang=en_nz')
59+
screen:expect([[
60+
"This is some text without any spell errors. Everything", |
61+
"should just be black, nothing wrong here.", |
62+
"", |
63+
"This line has a {1:sepll} error. {2:and} missing caps.", |
64+
"{1:And and} this is {1:the the} duplication.", |
65+
"with missing caps here.", |
66+
^ |
67+
|
68+
]])
69+
end)
4570
end)

0 commit comments

Comments
 (0)