vim: Handle exclusive-linewise edgecase correctly (#27786)
Before this change we didn't explicitly handle vim's exclusive-linewise edgecase (https://neovim.io/doc/user/motion.html#exclusive). Instead we had hard-coded workarounds in a few places to make our tests pass. The most pernicious of these workarounds was that we represented a visual line selection as including the trailing newline (or leading newline for files that end with no newline), which other code had to undo to get back to what the user indended. Closes #21440 Updates #6900 Release Notes: - vim: Fixed `d]}` to not delete the closing brace - vim: Fixed `d}` from the start of the line to not delete the paragraph separator - vim: Fixed `d}` from the middle of the line to not delete the final newline
This commit is contained in:
parent
e1e8c1786e
commit
fc269dfaf9
27 changed files with 471 additions and 482 deletions
14
crates/vim/test_data/test_delete_paragraph.json
Normal file
14
crates/vim/test_data/test_delete_paragraph.json
Normal file
|
@ -0,0 +1,14 @@
|
|||
{"Put":{"state":"helˇlo world.\n\nhello world.\n"}}
|
||||
{"Key":"y"}
|
||||
{"Key":"}"}
|
||||
{"Key":"d"}
|
||||
{"Key":"}"}
|
||||
{"Get":{"state":"heˇl\n\nhello world.\n","mode":"Normal"}}
|
||||
{"ReadRegister":{"name":"\"","value":"lo world."}}
|
||||
{"Get":{"state":"heˇl\n\nhello world.\n","mode":"Normal"}}
|
||||
{"Put":{"state":"ˇhello world.\n\nhello world.\n"}}
|
||||
{"Key":"y"}
|
||||
{"Key":"}"}
|
||||
{"Key":"d"}
|
||||
{"Key":"}"}
|
||||
{"Get":{"state":"ˇ\nhello world.\n","mode":"Normal"}}
|
18
crates/vim/test_data/test_delete_paragraph_motion.json
Normal file
18
crates/vim/test_data/test_delete_paragraph_motion.json
Normal file
|
@ -0,0 +1,18 @@
|
|||
{"Put":{"state":"ˇhello world.\n\nhello world.\n"}}
|
||||
{"Key":"y"}
|
||||
{"Key":"}"}
|
||||
{"Get":{"state":"ˇhello world.\n\nhello world.\n","mode":"Normal"}}
|
||||
{"ReadRegister":{"name":"\"","value":"hello world.\n"}}
|
||||
{"Key":"d"}
|
||||
{"Key":"}"}
|
||||
{"Get":{"state":"ˇ\nhello world.\n","mode":"Normal"}}
|
||||
{"ReadRegister":{"name":"\"","value":"hello world.\n"}}
|
||||
{"Put":{"state":"helˇlo world.\n\nhello world.\n"}}
|
||||
{"Key":"y"}
|
||||
{"Key":"}"}
|
||||
{"Get":{"state":"helˇlo world.\n\nhello world.\n","mode":"Normal"}}
|
||||
{"ReadRegister":{"name":"\"","value":"lo world."}}
|
||||
{"Key":"d"}
|
||||
{"Key":"}"}
|
||||
{"Get":{"state":"heˇl\n\nhello world.\n","mode":"Normal"}}
|
||||
{"ReadRegister":{"name":"\"","value":"lo world."}}
|
|
@ -1,17 +1,3 @@
|
|||
{"Put":{"state":"Fiˇrst. Second. Third.\nFourth.\n"}}
|
||||
{"Key":"d"}
|
||||
{"Key":")"}
|
||||
{"Get":{"state":"FiˇSecond. Third.\nFourth.\n","mode":"Normal"}}
|
||||
{"Put":{"state":"First. Secˇond. Third.\nFourth.\n"}}
|
||||
{"Key":"d"}
|
||||
{"Key":")"}
|
||||
{"Get":{"state":"First. SecˇThird.\nFourth.\n","mode":"Normal"}}
|
||||
{"Put":{"state":"First. Second. Thirˇd.\nFourth.\n"}}
|
||||
{"Key":"d"}
|
||||
{"Key":")"}
|
||||
{"Key":"d"}
|
||||
{"Key":")"}
|
||||
{"Get":{"state":"First. Second. Thˇi\n","mode":"Normal"}}
|
||||
{"Put":{"state":"ˇFirst.\nFourth.\n"}}
|
||||
{"Key":"d"}
|
||||
{"Key":")"}
|
||||
|
|
12
crates/vim/test_data/test_delete_unmatched_brace.json
Normal file
12
crates/vim/test_data/test_delete_unmatched_brace.json
Normal file
|
@ -0,0 +1,12 @@
|
|||
{"Put":{"state":"fn o(wow: i32) {\n dbgˇ!(wow)\n dbg!(wow)\n}\n"}}
|
||||
{"Key":"d"}
|
||||
{"Key":"]"}
|
||||
{"Key":"}"}
|
||||
{"Get":{"state":"fn o(wow: i32) {\n dbˇg\n}\n","mode":"Normal"}}
|
||||
{"ReadRegister":{"name":"\"","value":"!(wow)\n dbg!(wow)"}}
|
||||
{"Put":{"state":"fn o(wow: i32) {\n ˇdbg!(wow)\n dbg!(wow)\n}\n"}}
|
||||
{"Key":"d"}
|
||||
{"Key":"]"}
|
||||
{"Key":"}"}
|
||||
{"Get":{"state":"fn o(wow: i32) {\nˇ}\n","mode":"Normal"}}
|
||||
{"ReadRegister":{"name":"\"","value":" dbg!(wow)\n dbg!(wow)\n"}}
|
|
@ -35,6 +35,7 @@
|
|||
{"Key":"shift-v"}
|
||||
{"Key":"d"}
|
||||
{"Get":{"state":"The quick brown\nthe laˇzy dog","mode":"Normal"}}
|
||||
{"ReadRegister":{"name":"\"","value":"fox jumps over\n"}}
|
||||
{"Key":"k"}
|
||||
{"Key":"shift-v"}
|
||||
{"Key":"p"}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue