Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pasting in multi-line prompt causes error in __fish_tokenizer_state #7782

Closed
mqudsi opened this issue Mar 5, 2021 · 7 comments
Closed

Pasting in multi-line prompt causes error in __fish_tokenizer_state #7782

mqudsi opened this issue Mar 5, 2021 · 7 comments
Labels
regression Something that used to work, but was broken, especially between releases
Milestone

Comments

@mqudsi
Copy link
Contributor

mqudsi commented Mar 5, 2021

I'm creating an issue for this for changelog purposes, since it is a regression introduced in 3.2.0

Some of the changes to fish_clipboard_paste in 3.2.0 broke pasting when the command line consisted of more than one line, caused by our old friend the forcible splitting of substituted process output on new lines with no good way to opt out.

e.g.

$ echo "
>     hello^v

This would result in an error:

__fish_tokenizer_state: Expected at most 1 args, got 2

because the output of (commandline -ct) is passed to __fish_tokenizer_state in fish_clipboard_paste, but it is forcibly split on new lines. (I'm pretty sure the exact same underlying process substitution has a lot of other bugs in completions everywhere.)

The problem is further exacerbated by the fact that any errors emitted by fish while the prompt is being edited cause corruption of the in-memory terminal state (actual and expected row/cell info differs) meaning that further input at the prompt is not visible or causes corruption of existing content until the screen is cleared (^L) or the commandline is repainted (commandline -f repaint).

There was no issue pasting in a multi-line prompt in 3.1.0.

@mqudsi mqudsi added this to the fish 3.2.1 milestone Mar 5, 2021
@mqudsi mqudsi added the regression Something that used to work, but was broken, especially between releases label Mar 5, 2021
@mqudsi mqudsi closed this as completed in e450190 Mar 5, 2021
mqudsi added a commit that referenced this issue Mar 5, 2021
faho added a commit that referenced this issue Mar 6, 2021
Instead of hacking in arbitrary characters to avoid splitting, just
use `string collect`.

This reverts commit e450190.

Fixes #7782, but nicer.
@z3ntu
Copy link
Contributor

z3ntu commented Apr 20, 2021

I'm still seeing this with $FISH_VERSION 3.2.1 (Arch Linux package version 3.2.1-1) with exactly this error: __fish_tokenizer_state: Expected at most 1 args, got 2

@faho
Copy link
Member

faho commented Apr 20, 2021

@z3ntu Do check that you have the correct __fish_tokenizer_state function (i.e. functions -D __fish_tokenizer_state says it's from /usr/share/fish/functions/__fish_tokenizer_state.fish) and are running the actual correct fish. I just tested the arch package and it works for me.

@z3ntu
Copy link
Contributor

z3ntu commented Apr 20, 2021

Not sure, I'm pretty sure I run proper fish 3.2.1 without any messing up any internal functions myself.. 😉

I do echo " enter & ctrl+shift+v for paste in Konsole/Yakuake

image

I also have the contents of this commit (also in 3.2.1) installed on my file system 10ef0d9

@z3ntu
Copy link
Contributor

z3ntu commented Apr 20, 2021

Seems the fix wasn't applied to share/functions/__fish_commandline_is_singlequoted.fish ? Editing /usr/share/fish/functions/__fish_commandline_is_singlequoted.fish and doing so it reads (commandline -ct | string collect) seems to work

@faho
Copy link
Member

faho commented Apr 20, 2021

functions -D fish_clipboard_paste?

@faho
Copy link
Member

faho commented Apr 20, 2021

Ah, yeah, that's it.

__fish_commandline_is_singlequoted should be removed (the comments say as much), but it's still used in the shared bindings for bracketed paste (i.e. not fish_clipboard_paste, which this was about and which is in many ways superior)

faho added a commit that referenced this issue Apr 20, 2021
Also removes our remaining use of
`__fish_commandline_is_singlequoted`.

See #7782.
@z3ntu
Copy link
Contributor

z3ntu commented Apr 20, 2021

Thanks! Seems __fish_start_bracketed_paste was the function that was called.. Applying that fix locally works fine (also with the __fish_commandline_is_singlequoted.fish change reverted) :)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
regression Something that used to work, but was broken, especially between releases
Projects
None yet
Development

No branches or pull requests

3 participants