mirror of
https://github.com/neovim/neovim.git
synced 2025-10-04 08:56:29 +00:00
fix(spell): correct spell move behavior without "noplainbuffer" (#20386)
This commit is contained in:
@@ -1344,14 +1344,14 @@ size_t spell_move_to(win_T *wp, int dir, bool allwords, bool curline, hlf_T *att
|
|||||||
: p - buf) > wp->w_cursor.col)) {
|
: p - buf) > wp->w_cursor.col)) {
|
||||||
col = (colnr_T)(p - buf);
|
col = (colnr_T)(p - buf);
|
||||||
|
|
||||||
bool can_spell = (wp->w_s->b_p_spo_flags & SPO_NPBUFFER) == 0;
|
bool can_spell = decor_spell_nav_col(wp, lnum, &decor_lnum, col, &decor_error);
|
||||||
|
|
||||||
if (!can_spell) {
|
if (!can_spell) {
|
||||||
can_spell = decor_spell_nav_col(wp, lnum, &decor_lnum, col, &decor_error);
|
if (has_syntax) {
|
||||||
}
|
(void)syn_get_id(wp, lnum, col, false, &can_spell, false);
|
||||||
|
} else {
|
||||||
if (!can_spell && has_syntax) {
|
can_spell = (wp->w_s->b_p_spo_flags & SPO_NPBUFFER) == 0;
|
||||||
(void)syn_get_id(wp, lnum, col, false, &can_spell, false);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!can_spell) {
|
if (!can_spell) {
|
||||||
|
@@ -19,6 +19,10 @@ describe("'spell'", function()
|
|||||||
[0] = {bold=true, foreground=Screen.colors.Blue},
|
[0] = {bold=true, foreground=Screen.colors.Blue},
|
||||||
[1] = {special = Screen.colors.Red, undercurl = true},
|
[1] = {special = Screen.colors.Red, undercurl = true},
|
||||||
[2] = {special = Screen.colors.Blue1, undercurl = true},
|
[2] = {special = Screen.colors.Blue1, undercurl = true},
|
||||||
|
[3] = {foreground = tonumber('0x6a0dad')},
|
||||||
|
[4] = {foreground = Screen.colors.Magenta},
|
||||||
|
[5] = {bold = true, foreground = Screen.colors.SeaGreen},
|
||||||
|
[6] = {foreground = Screen.colors.Red},
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -68,4 +72,94 @@ describe("'spell'", function()
|
|||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('"noplainbuffer" and syntax #20385', function()
|
||||||
|
command('set filetype=c')
|
||||||
|
command('syntax on')
|
||||||
|
command('set spell')
|
||||||
|
insert([[
|
||||||
|
#include <stdbool.h>
|
||||||
|
bool func(void);]])
|
||||||
|
screen:expect([[
|
||||||
|
{3:#include }{4:<stdbool.h>} |
|
||||||
|
{5:bool} func({5:void})^; |
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
feed('[s')
|
||||||
|
screen:expect([[
|
||||||
|
{3:#include }{4:<stdbool.h>} |
|
||||||
|
{5:bool} func({5:void})^; |
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{6:search hit TOP, continuing at BOTTOM} |
|
||||||
|
]])
|
||||||
|
-- "noplainbuffer" shouldn't change spellchecking behavior with syntax enabled
|
||||||
|
command('set spelloptions+=noplainbuffer')
|
||||||
|
screen:expect_unchanged()
|
||||||
|
feed(']s')
|
||||||
|
screen:expect([[
|
||||||
|
{3:#include }{4:<stdbool.h>} |
|
||||||
|
{5:bool} func({5:void})^; |
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{6:search hit BOTTOM, continuing at TOP} |
|
||||||
|
]])
|
||||||
|
-- no spellchecking with "noplainbuffer" and syntax disabled
|
||||||
|
command('syntax off')
|
||||||
|
screen:expect([[
|
||||||
|
#include <stdbool.h> |
|
||||||
|
bool func(void)^; |
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{6:search hit BOTTOM, continuing at TOP} |
|
||||||
|
]])
|
||||||
|
feed('[s')
|
||||||
|
screen:expect([[
|
||||||
|
#include <stdbool.h> |
|
||||||
|
bool func(void)^; |
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{6:search hit TOP, continuing at BOTTOM} |
|
||||||
|
]])
|
||||||
|
-- everything is spellchecked without "noplainbuffer" with syntax disabled
|
||||||
|
command('set spelloptions&')
|
||||||
|
screen:expect([[
|
||||||
|
#include <{1:stdbool}.h> |
|
||||||
|
{1:bool} {1:func}(void)^; |
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{6:search hit TOP, continuing at BOTTOM} |
|
||||||
|
]])
|
||||||
|
feed(']s')
|
||||||
|
screen:expect([[
|
||||||
|
#include <{1:^stdbool}.h> |
|
||||||
|
{1:bool} {1:func}(void); |
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{6:search hit BOTTOM, continuing at TOP} |
|
||||||
|
]])
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user