Line wrapping issues

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Line wrapping issues

Leon Klingele
I'm experiencing line wrapping issues when using bash with fzf[1].
The issue is described in [2] and it looks like it is not caused by fzf
but instead by bash itself.

For the sake of completeness, here are the steps to reproduce:

1. Use bash with fzf, this requires you to install fzf. See [3].
2. Do an echo "abc abc abc abc abc abc abc abc abc abc abc abc abc abc
abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc" (so
you have that command in your bash history)
3. export PS1="abc abc abc abc abc abc abc abc abc abc abc abc abc abc
abc"
4. Activate fzf's reverse-i-search (Ctrl + r) (you need to have
sourc'ed fzf's $HOME/.fzf.bash file)
5. Select the echo "abc .." line, press enter
6. Bash prompt is wrapped incorrectly. After pressing enter in the last
step, the cursor is placed at the very end of the line (right after the
closing "), however there is more text on the right side of the cursor
(after EOL). See this screencast[4].

Is this problem caused by bash?

[1]: https://github.com/junegunn/fzf
[2]: https://github.com/junegunn/fzf/issues/994
[3]: https://github.com/junegunn/fzf#installation
[4]: https://git.io/v7MCY


signature.asc (817 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Line wrapping issues

Leon Klingele
Oh, I forgot to include my bash version (installed with Homebrew):
$ echo $BASH_VERSION
4.4.12(1)-release

signature.asc (817 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Line wrapping issues

Ángel González
On 2017-08-10 Leon Klingele wrote:
> Is this problem caused by bash?
>
Most likely, something done by fzf is not "completely right" as in fzf
sets up things in a way that bash is then unable to determine the right
width of the line it was asked to print.

I guess the sourced file corresponds to this script?
https://github.com/junegunn/fzf/blob/master/shell/completion.bash

Regards


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Line wrapping issues

DJ Mills
Holy crap there is some nasty stuff in that script.

You can try shopt -s checkwinsize to see if that helps

On Mon, Aug 14, 2017 at 9:06 AM, Ángel <[hidden email]> wrote:

> On 2017-08-10 Leon Klingele wrote:
> > Is this problem caused by bash?
> >
> Most likely, something done by fzf is not "completely right" as in fzf
> sets up things in a way that bash is then unable to determine the right
> width of the line it was asked to print.
>
> I guess the sourced file corresponds to this script?
> https://github.com/junegunn/fzf/blob/master/shell/completion.bash
>
> Regards
>
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Line wrapping issues

Leon Klingele
In reply to this post by Leon Klingele
On 2017-08-14 Ángel wrote:
> I guess the sourced file corresponds to this script?
> https://github.com/junegunn/fzf/blob/master/shell/completion.bash
Yes.

On 2017-08-14 DJ Mills wrote:
> You can try shopt -s checkwinsize to see if that helps
checkwinsize is already enabled :/

How to debug this?

signature.asc (817 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Line wrapping issues

L A Walsh
Leon Klingele wrote:
> How to debug this?
Try removing all functionality in fzf that still allows you to
reproduce the bug.

'fzf' is producing "some output" which is causing confusion;
trying to narrow that down would be the likely way to proceed.

Alternatively, you might try running your combination in something
that stores all I/O.  Googling 'recording a tty session' will
bring up several programs that work to record a session.

Then you can find the output that is causing the confusion.
Then its a matter of determining if it is the correct output
and if so, put it in a separate shell script and "echo"
it to output as a demo of how the [correct?] output causes
bash to misbehave.  Either that or you'll see that the output
isn't correct for what you are wanting it to do.

(I.e. if you were expecting it to goto a new line on linux
and it only put out a 'CR', you'd see that the output was
incorrect).

Make sense?



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Line wrapping issues

Leon Klingele
> you might try running your combination in something that stores
> all I/O

Awesome idea! I did record a session with 'script'.
Replay it as follows:

$ git clone https://gist.github.com/leonklingele/e3e3754cc0362e0e982823709db032eb bash-fzf
$ cd $_
$ cat typescript

Now take a look at the second line which ends as follows:
abc abc abc"abc abc abc
The last three abc blocks (after the closing quote) shouldn't be there.

This must be caused by some of the control characters.

signature.asc (817 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Line wrapping issues

Chet Ramey
In reply to this post by Leon Klingele
On 8/9/17 10:30 PM, Leon Klingele wrote:

> I'm experiencing line wrapping issues when using bash with fzf[1].
> The issue is described in [2] and it looks like it is not caused by fzf
> but instead by bash itself.
>
> For the sake of completeness, here are the steps to reproduce:
>
> 1. Use bash with fzf, this requires you to install fzf. See [3].
> 2. Do an echo "abc abc abc abc abc abc abc abc abc abc abc abc abc abc
> abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc" (so
> you have that command in your bash history)
> 3. export PS1="abc abc abc abc abc abc abc abc abc abc abc abc abc abc
> abc"
> 4. Activate fzf's reverse-i-search (Ctrl + r) (you need to have
> sourc'ed fzf's $HOME/.fzf.bash file)
> 5. Select the echo "abc .." line, press enter

If these steps leave the cursor in a different position than readline
expects it to be (before step 4), even the redraw-current-line at the
end of the macro may not help. You could try replacing the key sequence
to redraw the current line with \c-l and see if that helps.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    [hidden email]    http://cnswww.cns.cwru.edu/~chet/

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Line wrapping issues

Chet Ramey
In reply to this post by Leon Klingele
On 8/20/17 5:50 PM, Leon Klingele wrote:
>> you might try running your combination in something that stores
>> all I/O
>
> Awesome idea! I did record a session with 'script'.

Please send your typescript to the list.

Chet


--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    [hidden email]    http://cnswww.cns.cwru.edu/~chet/

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Line wrapping issues

Leon Klingele
> Please send your typescript to the list.

Here you go (see attachment).

> If these steps leave the cursor in a different position than readline
> expects it to be (before step 4), even the redraw-current-line at the
> end of the macro may not help. You could try replacing the key sequence
> to redraw the current line with \c-l and see if that helps.

I can't quite follow you. Which "key sequence" are you referring to?
Pressing Ctrl+l indeed fixes the issue but also clears the screen
which I'd try to avoid -> only a workaround.





typescript (13K) Download Attachment
signature.asc (817 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Line wrapping issues

Chet Ramey
On 8/21/17 1:29 PM, Leon Klingele wrote:
>> Please send your typescript to the list.
>
> Here you go (see attachment).

Thanks. I'll see if it reveals anything I don't expect.

>> If these steps leave the cursor in a different position than readline
>> expects it to be (before step 4), even the redraw-current-line at the
>> end of the macro may not help. You could try replacing the key sequence
>> to redraw the current line with \c-l and see if that helps.
>
> I can't quite follow you. Which "key sequence" are you referring to?
> Pressing Ctrl+l indeed fixes the issue but also clears the screen
> which I'd try to avoid -> only a workaround.

The fzf redefinition of the ^R key sequence as a macro.  That macro ends
with \C-x\C-r, which it redefines to bind to "redraw-current-line". If
you replace those characters with \C-l, does it redraw correctly (after
clearing the screen, of course)?

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    [hidden email]    http://cnswww.cns.cwru.edu/~chet/


signature.asc (231 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Line wrapping issues

Leon Klingele
> That macro ends with \C-x\C-r

Actually it ends in \e^\er, it lands in the if-block for me:
https://github.com/junegunn/fzf/blob/55ee4186aa688e524e041971d588a6f002486deb/shell/key-bindings.bash#L83

Replacing \C-r with \C-l "solves" the issue, but again clears the
screen which I'd try to avoid.

Are you unable to reproduce the issue?

signature.asc (817 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Line wrapping issues

Chet Ramey
On 8/22/17 2:26 PM, Leon Klingele wrote:
>> That macro ends with \C-x\C-r
>
> Actually it ends in \e^\er, it lands in the if-block for me:
> https://github.com/junegunn/fzf/blob/55ee4186aa688e524e041971d588a6f002486deb/shell/key-bindings.bash#L83

Ah, you're using the vi-mode binding. Yes, it applies equally to that
version, replacing the `\er', which is bound to redraw-current-line,
with \C-l.

>
> Replacing \C-r with \C-l "solves" the issue, but again clears the
> screen which I'd try to avoid.

I understand you'd like to avoid that.

>
> Are you unable to reproduce the issue?

I'd prefer not to install the ton of software I need to try and replicate
it, so I'm looking at what those who have can tell me.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    [hidden email]    http://cnswww.cns.cwru.edu/~chet/


signature.asc (231 bytes) Download Attachment
Loading...