farosis / vim

Automatically exported from code.google.com/p/vim
0 stars 0 forks source link

setreg(..., ..., 'al') keeps appending newlines #323

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Select a charwise text into a register
2. Do :call setreg('"', '', 'al') to transform it into a linewise register
3. Paste, everything works (check with :reg ")
4. Do :call setreg('"', '', 'al') to transform it into a linewise register again
5. Paste, now there's 2 newlines in the register (check with :reg ")

What is the expected output? What do you see instead?

I would expect that if a register is already linewise, it wouldn't get any 
extra newlines.

What version of the product are you using? On what operating system?

Vim 4.7.488 on OSX 10.10.1

Please provide any additional information below.

From the documentation I could not find out whether this was intentional or 
not. I suspect not as in the original conversation when this feature was added 
in 2002, Bram mentioned that it would be neat if it could be used to save and 
restore registers.

Original issue reported on code.google.com by nicolash...@gmail.com on 27 Jan 2015 at 1:16

GoogleCodeExporter commented 9 years ago
Here is a patch, that adds some tests. Since the test_eval.ok file makes diff 
create a binary patch file, one needs to use hg import to use it.

Test-Suite successful run https://travis-ci.org/chrisbra/vim-ci/jobs/48670960

Original comment by chrisbr...@googlemail.com on 28 Jan 2015 at 8:20

Attachments:

GoogleCodeExporter commented 9 years ago
At first I thought this solution might not be sufficiently general. Yet, trying 
to come up with other cases where I wouldn't want a newline to be appended, I 
couldn't. So perhaps setreg(..., '', 'a' ...) is indeed the only one that's 
handled in a strange way.

Thanks for the patch!

Original comment by nicolash...@gmail.com on 28 Jan 2015 at 8:32