comparison src/testdir/test_textprop.vim @ 15349:6abee072b93c v8.1.0682

patch 8.1.0682: text properties not adjusted when backspacing replaced text commit https://github.com/vim/vim/commit/196d157f12cf0476d97f78834155fc67d6b161de Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jan 2 23:47:18 2019 +0100 patch 8.1.0682: text properties not adjusted when backspacing replaced text Problem: Text properties are not adjusted when backspacing replaced text. Solution: Keep text properties on text restored in replace mode.
author Bram Moolenaar <Bram@vim.org>
date Thu, 03 Jan 2019 00:00:54 +0100
parents f6b522596993
children 45f36b66a032
comparison
equal deleted inserted replaced
15348:24c31bd03f3a 15349:6abee072b93c
141 unlet props[1] 141 unlet props[1]
142 call assert_equal(props, prop_list(1)) 142 call assert_equal(props, prop_list(1))
143 143
144 call DeletePropTypes() 144 call DeletePropTypes()
145 bwipe! 145 bwipe!
146 endfunc
147
148 func SetupOneLine()
149 call setline(1, 'xonex xtwoxx')
150 call AddPropTypes()
151 call prop_add(1, 2, {'length': 3, 'id': 11, 'type': 'one'})
152 call prop_add(1, 8, {'length': 3, 'id': 12, 'type': 'two'})
153 let expected = [
154 \ {'col': 2, 'length': 3, 'id': 11, 'type': 'one', 'start': 1, 'end': 1},
155 \ {'col': 8, 'length': 3, 'id': 12, 'type': 'two', 'start': 1, 'end': 1},
156 \]
157 call assert_equal(expected, prop_list(1))
158 return expected
146 endfunc 159 endfunc
147 160
148 func Test_prop_add_remove_buf() 161 func Test_prop_add_remove_buf()
149 new 162 new
150 let bufnr = bufnr('') 163 let bufnr = bufnr('')
178 endfunc 191 endfunc
179 192
180 func Test_prop_backspace() 193 func Test_prop_backspace()
181 new 194 new
182 set bs=2 195 set bs=2
183 call setline(1, 'xonex xtwoxx') 196 let expected = SetupOneLine() " 'xonex xtwoxx'
184 call AddPropTypes()
185 call prop_add(1, 2, {'length': 3, 'id': 11, 'type': 'one'})
186 call prop_add(1, 8, {'length': 3, 'id': 12, 'type': 'two'})
187 let expected = [
188 \ {'col': 2, 'length': 3, 'id': 11, 'type': 'one', 'start': 1, 'end': 1},
189 \ {'col': 8, 'length': 3, 'id': 12, 'type': 'two', 'start': 1, 'end': 1},
190 \]
191 call assert_equal(expected, prop_list(1))
192 197
193 exe "normal 0li\<BS>\<Esc>fxli\<BS>\<Esc>" 198 exe "normal 0li\<BS>\<Esc>fxli\<BS>\<Esc>"
194 call assert_equal('one xtwoxx', getline(1)) 199 call assert_equal('one xtwoxx', getline(1))
195 let expected[0].col = 1 200 let expected[0].col = 1
196 let expected[1].col = 6 201 let expected[1].col = 6
202 call assert_equal(expected, prop_list(1))
203
204 call DeletePropTypes()
205 bwipe!
206 set bs&
207 endfunc
208
209 func Test_prop_replace()
210 new
211 set bs=2
212 let expected = SetupOneLine() " 'xonex xtwoxx'
213
214 exe "normal 0Ryyy\<Esc>"
215 call assert_equal('yyyex xtwoxx', getline(1))
216 call assert_equal(expected, prop_list(1))
217
218 exe "normal ftRyy\<BS>"
219 call assert_equal('yyyex xywoxx', getline(1))
220 call assert_equal(expected, prop_list(1))
221
222 exe "normal 0fwRyy\<BS>"
223 call assert_equal('yyyex xyyoxx', getline(1))
224 call assert_equal(expected, prop_list(1))
225
226 exe "normal 0foRyy\<BS>\<BS>"
227 call assert_equal('yyyex xyyoxx', getline(1))
197 call assert_equal(expected, prop_list(1)) 228 call assert_equal(expected, prop_list(1))
198 229
199 call DeletePropTypes() 230 call DeletePropTypes()
200 bwipe! 231 bwipe!
201 set bs& 232 set bs&