Fix pasteinto error when clipboard text has surrounding whitespace. (#262)

`pasteinto` is called by `surroundFunc` which a string into whitespace
delimited arguments. Surrounding whitespace in the link to be copied
thus errors due to an unhandled number of arguments.

The now fixed error can be recreated by using `yy` to yank a line and
then using <A-p> to paste the link over a word. Similarly, `yW` will
reproduce the error if the link has a trailing whitespace.

`pasteinto` will still error if the link contains internal whitespace,
but this is more reasonable behavior. Fixing this will require tweaking
the regex `surroundFunc` uses to split up arguments.
This commit is contained in:
Juan Luque 2025-04-09 01:47:08 -04:00 committed by GitHub
parent 47de579471
commit 4aa4ca31f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -521,7 +521,7 @@ export default class VimrcPlugin extends Plugin {
// Using the register for when this.yankToSystemClipboard == false
surroundFunc(
['[',
'](' + vimObject.getRegisterController().getRegister('yank').keyBuffer + ")"]);
'](' + vimObject.getRegisterController().getRegister('yank').keyBuffer[0].trim() + ")"]);
})
var editor = this.getActiveView().editor;