diff src/testdir/test_textprop.vim @ 28848:ba81f4ed59e2 v8.2.4947

patch 8.2.4947: text properties not adjusted when accepting spell suggestion Commit: https://github.com/vim/vim/commit/b7a701255578b38896631ba20556b856e8888069 Author: LemonBoy <thatlemon@gmail.com> Date: Fri May 13 12:41:50 2022 +0100 patch 8.2.4947: text properties not adjusted when accepting spell suggestion Problem: Text properties not adjusted when accepting spell suggestion. Solution: Adjust text properties when text changes. (closes https://github.com/vim/vim/issues/10414)
author Bram Moolenaar <Bram@vim.org>
date Fri, 13 May 2022 13:45:03 +0200
parents 77a00aa3e215
children 647d7f439622
line wrap: on
line diff
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -1889,4 +1889,49 @@ func Test_prop_find_prev_on_same_line()
   bwipe!
 endfunc
 
+func Test_prop_spell()
+  new
+  set spell
+  call AddPropTypes()
+
+  call setline(1, ["helo world", "helo helo helo"])
+  call prop_add(1, 1, #{type: 'one', length: 4})
+  call prop_add(1, 6, #{type: 'two', length: 5})
+  call prop_add(2, 1, #{type: 'three', length: 4})
+  call prop_add(2, 6, #{type: 'three', length: 4})
+  call prop_add(2, 11, #{type: 'three', length: 4})
+
+  " The first prop over 'helo' increases its length after the word is corrected
+  " to 'Hello', the second one is shifted to the right.
+  let expected = [
+      \ {'id': 0, 'col': 1, 'type_bufnr': 0, 'end': 1, 'type': 'one',
+      \ 'length': 5, 'start': 1},
+      \ {'id': 0, 'col': 7, 'type_bufnr': 0, 'end': 1, 'type': 'two',
+      \ 'length': 5, 'start': 1}
+      \ ]
+  call feedkeys("z=1\<CR>", 'xt')
+
+  call assert_equal('Hello world', getline(1))
+  call assert_equal(expected, prop_list(1))
+
+  " Repeat the replacement done by z=
+  spellrepall
+
+  let expected = [
+      \ {'id': 0, 'col': 1, 'type_bufnr': 0, 'end': 1, 'type': 'three',
+      \ 'length': 5, 'start': 1},
+      \ {'id': 0, 'col': 7, 'type_bufnr': 0, 'end': 1, 'type': 'three',
+      \ 'length': 5, 'start': 1},
+      \ {'id': 0, 'col': 13, 'type_bufnr': 0, 'end': 1, 'type': 'three',
+      \ 'length': 5, 'start': 1}
+      \ ]
+  call assert_equal('Hello Hello Hello', getline(2))
+  call assert_equal(expected, prop_list(2))
+
+  call DeletePropTypes()
+  set spell&
+  bwipe!
+endfunc
+
+
 " vim: shiftwidth=2 sts=2 expandtab