diff options
| author | Johannes Altmanninger <aclopte@gmail.com> | 2025-05-10 21:39:28 +0200 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2025-05-11 10:08:43 +1000 |
| commit | 3dac6e28ef2baaf01924a6b71310fc18d0a3c17e (patch) | |
| tree | 1be732452f6631b1c91a69816ac1ce10b97521b9 /src/buffer_utils.hh | |
| parent | 23ea6e6a5230a62fc4c183b1898efb550db0c347 (diff) | |
Use linewise paste only if register is missing no trailing newline
We use linewise paste if any of the pasted register elements has a trailing
newline. As shown in the previous patch, this leads to awkward situations
where insertion positions from <a-P> are not monotonically increasing.
This complicated behavior is questionable. The root cause is that linewise
paste may insert some strings that don't have a trailing newline. This leads
to weird cases of GIGO, especially when using <a-P> when the last element
is missing a trailing newline.
Simplify the implementation by not activating linewise paste in that case.
Instead of special-casing the last element, try to simplify the behavior
further by using line-wise paste only if *all* elements are properly
terminated. I can't think of a real-world case where the existing behavior
would be desired.
A regression test shows a change in behavior. Might be less weird now.
The added test case is a copy except it uses "P" instead of "p" (the extra
newline is because "d" deletes the last newline in the buffer which gets
added back implicitly).
(I think the list of register elements is never empty, so this should never
cause a trivial linewise paste. Even if so, that would be fine because
inserting nothing is a nop either way.)
Fixes #5312
Diffstat (limited to 'src/buffer_utils.hh')
0 files changed, 0 insertions, 0 deletions
