From a803bff89c89cc63e549a3c791fa07d91d1106c8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 1 May 2023 12:30:55 +0800 Subject: fix(spell): extmark with spell=false should disable spell (#23400) --- test/functional/ui/spell_spec.lua | 139 +++++++++++++++++++++++++++++++------- 1 file changed, 115 insertions(+), 24 deletions(-) (limited to 'test/functional/ui/spell_spec.lua') diff --git a/test/functional/ui/spell_spec.lua b/test/functional/ui/spell_spec.lua index 361f83d1ce..15819aef40 100644 --- a/test/functional/ui/spell_spec.lua +++ b/test/functional/ui/spell_spec.lua @@ -6,6 +6,8 @@ local clear = helpers.clear local feed = helpers.feed local insert = helpers.insert local command = helpers.command +local meths = helpers.meths +local curbufmeths = helpers.curbufmeths local is_os = helpers.is_os describe("'spell'", function() @@ -18,11 +20,13 @@ describe("'spell'", function() screen:set_default_attr_ids( { [0] = {bold=true, foreground=Screen.colors.Blue}, [1] = {special = Screen.colors.Red, undercurl = true}, - [2] = {special = Screen.colors.Blue1, undercurl = true}, + [2] = {special = Screen.colors.Blue, undercurl = true}, [3] = {foreground = tonumber('0x6a0dad')}, [4] = {foreground = Screen.colors.Magenta}, [5] = {bold = true, foreground = Screen.colors.SeaGreen}, [6] = {foreground = Screen.colors.Red}, + [7] = {foreground = Screen.colors.Blue}, + [8] = {foreground = Screen.colors.Blue, special = Screen.colors.Red, undercurl = true}, }) end) @@ -74,19 +78,57 @@ describe("'spell'", function() ]]) end) - it('"noplainbuffer" and syntax #20385', function() + it('extmarks, "noplainbuffer" and syntax #20385 #23398', function() command('set filetype=c') command('syntax on') command('set spell') insert([[ #include - bool func(void);]]) + bool func(void); + // I am a speling mistakke]]) + feed('ge') screen:expect([[ {3:#include }{4:} | - {5:bool} func({5:void})^; | + {5:bool} func({5:void}); | + {7:// I am a }{8:spelin^g}{7: }{8:mistakke} | {0:~ }| {0:~ }| {0:~ }| + {0:~ }| + | + ]]) + feed(']s') + screen:expect([[ + {3:#include }{4:} | + {5:bool} func({5:void}); | + {7:// I am a }{8:speling}{7: }{8:^mistakke} | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + feed(']s') + screen:expect([[ + {3:#include }{4:} | + {5:bool} func({5:void}); | + {7:// I am a }{8:^speling}{7: }{8:mistakke} | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {6:search hit BOTTOM, continuing at TOP} | + ]]) + command('echo ""') + local ns = meths.create_namespace("spell") + -- extmark with spell=true enables spell + local id = curbufmeths.set_extmark(ns, 1, 4, { end_row = 1, end_col = 10, spell = true }) + screen:expect([[ + {3:#include }{4:} | + {5:bool} {1:func}({5:void}); | + {7:// I am a }{8:^speling}{7: }{8:mistakke} | + {0:~ }| + {0:~ }| {0:~ }| {0:~ }| | @@ -94,73 +136,122 @@ describe("'spell'", function() feed('[s') screen:expect([[ {3:#include }{4:} | - {5:bool} func({5:void})^; | + {5:bool} {1:^func}({5:void}); | + {7:// I am a }{8:speling}{7: }{8:mistakke} | + {0:~ }| + {0:~ }| {0:~ }| + {0:~ }| + | + ]]) + curbufmeths.del_extmark(ns, id) + -- extmark with spell=false disables spell + id = curbufmeths.set_extmark(ns, 2, 18, { end_row = 2, end_col = 26, spell = false }) + screen:expect([[ + {3:#include }{4:} | + {5:bool} ^func({5:void}); | + {7:// I am a }{8:speling}{7: mistakke} | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + feed('[s') + screen:expect([[ + {3:#include }{4:} | + {5:bool} func({5:void}); | + {7:// I am a }{8:^speling}{7: mistakke} | {0:~ }| {0:~ }| {0:~ }| {0:~ }| {6:search hit TOP, continuing at BOTTOM} | ]]) + command('echo ""') + curbufmeths.del_extmark(ns, id) + screen:expect([[ + {3:#include }{4:} | + {5:bool} func({5:void}); | + {7:// I am a }{8:^speling}{7: }{8:mistakke} | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + feed(']s') + screen:expect([[ + {3:#include }{4:} | + {5:bool} func({5:void}); | + {7:// I am a }{8:speling}{7: }{8:^mistakke} | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) -- "noplainbuffer" shouldn't change spellchecking behavior with syntax enabled command('set spelloptions+=noplainbuffer') screen:expect_unchanged() - feed(']s') + feed('[s') screen:expect([[ {3:#include }{4:} | - {5:bool} func({5:void})^; | - {0:~ }| + {5:bool} func({5:void}); | + {7:// I am a }{8:^speling}{7: }{8:mistakke} | {0:~ }| {0:~ }| {0:~ }| {0:~ }| - {6:search hit BOTTOM, continuing at TOP} | + | ]]) -- no spellchecking with "noplainbuffer" and syntax disabled command('syntax off') screen:expect([[ #include | - bool func(void)^; | + bool func(void); | + // I am a ^speling mistakke | {0:~ }| {0:~ }| {0:~ }| {0:~ }| - {0:~ }| - {6:search hit BOTTOM, continuing at TOP} | + | ]]) - feed('[s') + feed(']s') screen:expect([[ #include | - bool func(void)^; | + bool func(void); | + // I am a ^speling mistakke | {0:~ }| {0:~ }| {0:~ }| {0:~ }| - {0:~ }| - {6:search hit TOP, continuing at BOTTOM} | + {6:search hit BOTTOM, continuing at TOP} | ]]) + command('echo ""') -- everything is spellchecked without "noplainbuffer" with syntax disabled command('set spelloptions&') screen:expect([[ #include <{1:stdbool}.h> | - {1:bool} {1:func}(void)^; | - {0:~ }| + {1:bool} {1:func}(void); | + // I am a {1:^speling} {1:mistakke} | {0:~ }| {0:~ }| {0:~ }| {0:~ }| - {6:search hit TOP, continuing at BOTTOM} | + | ]]) - feed(']s') + feed('[s') screen:expect([[ - #include <{1:^stdbool}.h> | - {1:bool} {1:func}(void); | - {0:~ }| + #include <{1:stdbool}.h> | + {1:bool} {1:^func}(void); | + // I am a {1:speling} {1:mistakke} | {0:~ }| {0:~ }| {0:~ }| {0:~ }| - {6:search hit BOTTOM, continuing at TOP} | + | ]]) end) + end) -- cgit From b11a8c1b5d3985479351b34f2078d490cbf59e90 Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Mon, 22 May 2023 11:07:55 +0200 Subject: fix(highlight): remove unnecessary assignment to char_attr for 'spell' (#23713) --- test/functional/ui/spell_spec.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/functional/ui/spell_spec.lua') diff --git a/test/functional/ui/spell_spec.lua b/test/functional/ui/spell_spec.lua index 15819aef40..0f553d4a9b 100644 --- a/test/functional/ui/spell_spec.lua +++ b/test/functional/ui/spell_spec.lua @@ -254,4 +254,19 @@ describe("'spell'", function() ]]) end) + it('and syntax does not clear extmark highlighting at the start of a word', function() + screen:try_resize(43, 3) + command([[ + set spell + syntax match Constant "^.*$" + call setline(1, "This is some text without any spell errors.") + ]]) + local ns = meths.create_namespace("spell") + curbufmeths.set_extmark(ns, 0, 0, { hl_group = 'WarningMsg', end_col = 43 }) + screen:expect([[ + {6:^This is some text without any spell errors.}| + {0:~ }| + | + ]]) + end) end) -- cgit From bff67c9fbe8c174dae8952a565a110930dc4fc58 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Wed, 24 May 2023 19:50:01 +0200 Subject: vim-patch:9.0.0175: spell checking for capital not working with trailing space Problem: Spell checking for capital not working with trailing space. Solution: Do not calculate cap_col at the end of the line. (Christian Brabandt, closes vim/vim#10870, issue vim/vim#10838) https://github.com/vim/vim/commit/afa23d1b99692e3c726eb694933ab348b442a1e4 Co-authored-by: Christian Brabandt --- test/functional/ui/spell_spec.lua | 83 ++++++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 28 deletions(-) (limited to 'test/functional/ui/spell_spec.lua') diff --git a/test/functional/ui/spell_spec.lua b/test/functional/ui/spell_spec.lua index 0f553d4a9b..c5c4ec3b99 100644 --- a/test/functional/ui/spell_spec.lua +++ b/test/functional/ui/spell_spec.lua @@ -3,9 +3,9 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear = helpers.clear +local exec = helpers.exec local feed = helpers.feed local insert = helpers.insert -local command = helpers.command local meths = helpers.meths local curbufmeths = helpers.curbufmeths local is_os = helpers.is_os @@ -32,7 +32,7 @@ describe("'spell'", function() it('joins long lines #7937', function() if is_os('openbsd') then pending('FIXME #12104', function() end) return end - command('set spell') + exec('set spell') insert([[ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, @@ -57,31 +57,58 @@ describe("'spell'", function() -- oldtest: Test_spell_screendump() it('has correct highlight at start of line', function() - insert([[ - "This is some text without any spell errors. Everything", - "should just be black, nothing wrong here.", - "", - "This line has a sepll error. and missing caps.", - "And and this is the the duplication.", - "with missing caps here.", + exec([=[ + call setline(1, [ + \"This is some text without any spell errors. Everything", + \"should just be black, nothing wrong here.", + \"", + \"This line has a sepll error. and missing caps.", + \"And and this is the the duplication.", + \"with missing caps here.", + \]) + set spell spelllang=en_nz + ]=]) + screen:expect([[ + ^This is some text without any spell errors. Everything | + should just be black, nothing wrong here. | + | + This line has a {1:sepll} error. {2:and} missing caps. | + {1:And and} this is {1:the the} duplication. | + {2:with} missing caps here. | + {0:~ }| + | ]]) - command('set spell spelllang=en_nz') + end) + + -- oldtest: Test_spell_screendump_spellcap() + it('has correct highlight at start of line with trailing space', function() + exec([=[ + call setline(1, [ + \" This line has a sepll error. and missing caps and trailing spaces. ", + \"another missing cap here.", + \"", + \"and here.", + \" ", + \"and here." + \]) + set spell spelllang=en + ]=]) screen:expect([[ - "This is some text without any spell errors. Everything", | - "should just be black, nothing wrong here.", | - "", | - "This line has a {1:sepll} error. {2:and} missing caps.", | - "{1:And and} this is {1:the the} duplication.", | - "with missing caps here.", | - ^ | - | + ^ This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. | + {2:another} missing cap here. | + | + {2:and} here. | + | + {2:and} here. | + {0:~ }| + | ]]) end) it('extmarks, "noplainbuffer" and syntax #20385 #23398', function() - command('set filetype=c') - command('syntax on') - command('set spell') + exec('set filetype=c') + exec('syntax on') + exec('set spell') insert([[ #include bool func(void); @@ -119,7 +146,7 @@ describe("'spell'", function() {0:~ }| {6:search hit BOTTOM, continuing at TOP} | ]]) - command('echo ""') + exec('echo ""') local ns = meths.create_namespace("spell") -- extmark with spell=true enables spell local id = curbufmeths.set_extmark(ns, 1, 4, { end_row = 1, end_col = 10, spell = true }) @@ -168,7 +195,7 @@ describe("'spell'", function() {0:~ }| {6:search hit TOP, continuing at BOTTOM} | ]]) - command('echo ""') + exec('echo ""') curbufmeths.del_extmark(ns, id) screen:expect([[ {3:#include }{4:} | @@ -192,7 +219,7 @@ describe("'spell'", function() | ]]) -- "noplainbuffer" shouldn't change spellchecking behavior with syntax enabled - command('set spelloptions+=noplainbuffer') + exec('set spelloptions+=noplainbuffer') screen:expect_unchanged() feed('[s') screen:expect([[ @@ -206,7 +233,7 @@ describe("'spell'", function() | ]]) -- no spellchecking with "noplainbuffer" and syntax disabled - command('syntax off') + exec('syntax off') screen:expect([[ #include | bool func(void); | @@ -228,9 +255,9 @@ describe("'spell'", function() {0:~ }| {6:search hit BOTTOM, continuing at TOP} | ]]) - command('echo ""') + exec('echo ""') -- everything is spellchecked without "noplainbuffer" with syntax disabled - command('set spelloptions&') + exec('set spelloptions&') screen:expect([[ #include <{1:stdbool}.h> | {1:bool} {1:func}(void); | @@ -256,7 +283,7 @@ describe("'spell'", function() it('and syntax does not clear extmark highlighting at the start of a word', function() screen:try_resize(43, 3) - command([[ + exec([[ set spell syntax match Constant "^.*$" call setline(1, "This is some text without any spell errors.") -- cgit From ad7cded1f3f40912d962796d6965dac17ecb97f0 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Wed, 24 May 2023 20:13:11 +0200 Subject: vim-patch:9.0.0590: after exiting Insert mode spelling not checked in next line Problem: After exiting Insert mode spelling is not checked in the next line. Solution: When spelling is enabled redraw the next line after exiting Insert mode in case the spell highlight needs updating. https://github.com/vim/vim/commit/ee09fcc9b6cf24e02899461809da9a5148208ea5 Co-authored-by: Bram Moolenaar --- test/functional/ui/spell_spec.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/functional/ui/spell_spec.lua') diff --git a/test/functional/ui/spell_spec.lua b/test/functional/ui/spell_spec.lua index c5c4ec3b99..5cfb85e431 100644 --- a/test/functional/ui/spell_spec.lua +++ b/test/functional/ui/spell_spec.lua @@ -103,6 +103,18 @@ describe("'spell'", function() {0:~ }| | ]]) + -- After adding word missing Cap in next line is updated + feed('3GANot') + screen:expect([[ + This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. | + {2:another} missing cap here. | + No^t | + and here. | + | + {2:and} here. | + {0:~ }| + | + ]]) end) it('extmarks, "noplainbuffer" and syntax #20385 #23398', function() -- cgit From d2dc7cfa5b930a1ff68426f3d47809508ac7d392 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Wed, 24 May 2023 20:26:03 +0200 Subject: vim-patch:9.0.0608: with spelling, deleting a full stop does not update next line Problem: With spell checking, deleting a full stop at the end of a line does not update SpellCap at the start of the next line. Solution: Update the next line when characters have been deleted. Also when using undo. https://github.com/vim/vim/commit/26f09ea54b2c60abf21df42c60bdfc60eca17b0d Co-authored-by: Bram Moolenaar --- test/functional/ui/spell_spec.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test/functional/ui/spell_spec.lua') diff --git a/test/functional/ui/spell_spec.lua b/test/functional/ui/spell_spec.lua index 5cfb85e431..800043b169 100644 --- a/test/functional/ui/spell_spec.lua +++ b/test/functional/ui/spell_spec.lua @@ -115,6 +115,30 @@ describe("'spell'", function() {0:~ }| | ]]) + -- Deleting a full stop removes missing Cap in next line + feed('5Gddk$x') + screen:expect([[ + This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. | + {2:another} missing cap here. | + Not | + and her^e | + and here. | + {0:~ }| + {0:~ }| + | + ]]) + -- Undo also updates the next line (go to command line to remove message) + feed('u:') + screen:expect([[ + This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. | + {2:another} missing cap here. | + Not | + and here^. | + {2:and} here. | + {0:~ }| + {0:~ }| + | + ]]) end) it('extmarks, "noplainbuffer" and syntax #20385 #23398', function() -- cgit From 50efdd6ccf1891392c048b92da5e5d123a30ff26 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Wed, 24 May 2023 20:41:58 +0200 Subject: vim-patch:9.0.0664: bad redrawing with spell checking, using "C" and "$" in 'cpo' Problem: Bad redrawing with spell checking, using "C" and "$" in 'cpo'. Solution: Do not redraw the next line when "$" is in 'cpo'. (closes vim/vim#11285) https://github.com/vim/vim/commit/f3ef026c9897f1d2e3fba47166a4771d507dae91 Co-authored-by: Bram Moolenaar --- test/functional/ui/spell_spec.lua | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'test/functional/ui/spell_spec.lua') diff --git a/test/functional/ui/spell_spec.lua b/test/functional/ui/spell_spec.lua index 800043b169..7f11b06f78 100644 --- a/test/functional/ui/spell_spec.lua +++ b/test/functional/ui/spell_spec.lua @@ -27,6 +27,7 @@ describe("'spell'", function() [6] = {foreground = Screen.colors.Red}, [7] = {foreground = Screen.colors.Blue}, [8] = {foreground = Screen.colors.Blue, special = Screen.colors.Red, undercurl = true}, + [9] = {bold = true}, }) end) @@ -141,6 +142,40 @@ describe("'spell'", function() ]]) end) + -- oldtest: Test_spell_compatible() + it([[redraws properly when using "C" and "$" is in 'cpo']], function() + exec([=[ + call setline(1, [ + \ "test "->repeat(20), + \ "", + \ "end", + \ ]) + set spell cpo+=$ + ]=]) + feed('51|C') + screen:expect([[ + {2:test} test test test test test test test test test ^test test test test test test | + test test test test$ | + | + {2:end} | + {0:~ }| + {0:~ }| + {0:~ }| + {9:-- INSERT --} | + ]]) + feed('x') + screen:expect([[ + {2:test} test test test test test test test test test x^est test test test test test | + test test test test$ | + | + {2:end} | + {0:~ }| + {0:~ }| + {0:~ }| + {9:-- INSERT --} | + ]]) + end) + it('extmarks, "noplainbuffer" and syntax #20385 #23398', function() exec('set filetype=c') exec('syntax on') -- cgit From f733595e795cd2b819cb8fd18327cd51f47b2124 Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Fri, 26 May 2023 02:08:18 +0200 Subject: vim-patch:9.0.1578: SpellCap highlight not always updated when needed (#23755) Problem: SpellCap highlight not always updated when needed. Solution: Handle updating line below closed fold and other situations where only part of the window is redrawn. (Luuk van Baal, closes vim/vim#12428, closes vim/vim#12420) https://github.com/vim/vim/commit/2ac6497f0ef186f0e3ba67d7f0a485bfb612bb08 --- test/functional/ui/spell_spec.lua | 42 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'test/functional/ui/spell_spec.lua') diff --git a/test/functional/ui/spell_spec.lua b/test/functional/ui/spell_spec.lua index 7f11b06f78..630d0d0948 100644 --- a/test/functional/ui/spell_spec.lua +++ b/test/functional/ui/spell_spec.lua @@ -28,6 +28,7 @@ describe("'spell'", function() [7] = {foreground = Screen.colors.Blue}, [8] = {foreground = Screen.colors.Blue, special = Screen.colors.Red, undercurl = true}, [9] = {bold = true}, + [10] = {background = Screen.colors.LightGrey, foreground = Screen.colors.DarkBlue}, }) end) @@ -82,7 +83,7 @@ describe("'spell'", function() end) -- oldtest: Test_spell_screendump_spellcap() - it('has correct highlight at start of line with trailing space', function() + it('SpellCap highlight at start of line', function() exec([=[ call setline(1, [ \" This line has a sepll error. and missing caps and trailing spaces. ", @@ -117,7 +118,7 @@ describe("'spell'", function() | ]]) -- Deleting a full stop removes missing Cap in next line - feed('5Gddk$x') + feed('5Gddk$x') screen:expect([[ This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. | {2:another} missing cap here. | @@ -140,6 +141,43 @@ describe("'spell'", function() {0:~ }| | ]]) + -- Folding an empty line does not remove Cap in next line + feed('uzfk:') + screen:expect([[ + This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. | + {2:another} missing cap here. | + Not | + {10:^+-- 2 lines: and here.·························································}| + {2:and} here. | + {0:~ }| + {0:~ }| + | + ]]) + -- Folding the end of a sentence does not remove Cap in next line + -- and editing a line does not remove Cap in current line + feed('Jzfkk$x') + screen:expect([[ + This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. | + {2:another} missing cap her^e | + {10:+-- 2 lines: Not·······························································}| + {2:and} here. | + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + -- Cap is correctly applied in the first row of a window + feed('') + screen:expect([[ + {2:another} missing cap her^e | + {10:+-- 2 lines: Not·······························································}| + {2:and} here. | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) end) -- oldtest: Test_spell_compatible() -- cgit From ac1ad9651e88eef1eea92fe5bd1497344c83dc53 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Wed, 31 May 2023 21:13:58 +0200 Subject: vim-patch:9.0.1595: line pointer becomes invalid when using spell checking Problem: Line pointer becomes invalid when using spell checking. Solution: Call ml_get() at the right places. (Luuk van Baal, closes vim/vim#12456) https://github.com/vim/vim/commit/e84c773d42e8b6ef0f8ae9b6c7312e0fd47909af --- test/functional/ui/spell_spec.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test/functional/ui/spell_spec.lua') diff --git a/test/functional/ui/spell_spec.lua b/test/functional/ui/spell_spec.lua index 630d0d0948..d18e19e5b2 100644 --- a/test/functional/ui/spell_spec.lua +++ b/test/functional/ui/spell_spec.lua @@ -178,6 +178,30 @@ describe("'spell'", function() {0:~ }| | ]]) + -- Adding an empty line does not remove Cap in "mod_bot" area + feed('zbO') + screen:expect([[ + This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. | + ^ | + {2:another} missing cap here | + {10:+-- 2 lines: Not·······························································}| + {2:and} here. | + {0:~ }| + {0:~ }| + | + ]]) + -- Multiple empty lines does not remove Cap in the line after + feed('O') + screen:expect([[ + This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. | + ^ | + | + {2:another} missing cap here | + {10:+-- 2 lines: Not·······························································}| + {2:and} here. | + {0:~ }| + | + ]]) end) -- oldtest: Test_spell_compatible() -- cgit