mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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)
afa23d1b99
Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
678548a2b4
commit
bff67c9fbe
@ -2188,12 +2188,13 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
||||
v = (ptr - line);
|
||||
if (has_spell && v >= word_end && v > cur_checked_col) {
|
||||
spell_attr = 0;
|
||||
if (c != 0 && ((!has_syntax && !no_plain_buffer) || can_spell)) {
|
||||
char *prev_ptr;
|
||||
char *prev_ptr = ptr - mb_l;
|
||||
// do not calculate cap_col at the end of the line or when
|
||||
// only white space is following
|
||||
if (c != 0 && (*skipwhite(prev_ptr) != NUL)
|
||||
&& ((!has_syntax && !no_plain_buffer) || can_spell)) {
|
||||
char *p;
|
||||
int len;
|
||||
hlf_T spell_hlf = HLF_COUNT;
|
||||
prev_ptr = ptr - mb_l;
|
||||
v -= mb_l - 1;
|
||||
|
||||
// Use nextline[] if possible, it has the start of the
|
||||
@ -2206,7 +2207,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
||||
cap_col -= (int)(prev_ptr - line);
|
||||
size_t tmplen = spell_check(wp, p, &spell_hlf, &cap_col, nochange);
|
||||
assert(tmplen <= INT_MAX);
|
||||
len = (int)tmplen;
|
||||
int len = (int)tmplen;
|
||||
word_end = (int)v + len;
|
||||
|
||||
// In Insert mode only highlight a word that
|
||||
|
@ -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.",
|
||||
]])
|
||||
command('set spell spelllang=en_nz')
|
||||
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.", |
|
||||
"with missing caps here.", |
|
||||
^ |
|
||||
|
|
||||
^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:~ }|
|
||||
|
|
||||
]])
|
||||
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 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 <stdbool.h>
|
||||
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:<stdbool.h>} |
|
||||
@ -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 <stdbool.h> |
|
||||
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.")
|
||||
|
@ -996,6 +996,29 @@ func Test_spell_screendump()
|
||||
call delete('XtestSpell')
|
||||
endfunc
|
||||
|
||||
func Test_spell_screendump_spellcap()
|
||||
CheckScreendump
|
||||
|
||||
let lines =<< trim END
|
||||
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
|
||||
END
|
||||
call writefile(lines, 'XtestSpellCap')
|
||||
let buf = RunVimInTerminal('-S XtestSpellCap', {'rows': 8})
|
||||
call VerifyScreenDump(buf, 'Test_spell_2', {})
|
||||
|
||||
" clean up
|
||||
call StopVimInTerminal(buf)
|
||||
call delete('XtestSpellCap')
|
||||
endfunc
|
||||
|
||||
let g:test_data_aff1 = [
|
||||
\"SET ISO8859-1",
|
||||
\"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ",
|
||||
|
Loading…
Reference in New Issue
Block a user