Maximus5 / ConEmu

Customizable Windows terminal with tabs, splits, quake-style, hotkeys and more
https://conemu.github.io/
BSD 3-Clause "New" or "Revised" License
8.55k stars 572 forks source link

Reverse-i-search (Ctrl-R) breaks in MSYS2 bash in ConEmu #2179

Open sdbbs opened 3 years ago

sdbbs commented 3 years ago

Versions

ConEmu build: ConEmu 200713 [64] prevews

OS version: Windows 10 x64

Used shell version (Far Manager, git-bash, cmd, powershell, cygwin, whatever): MSYS2 bash (MSYS2 is basically just a collection of packages installed on your computer, managed by a package manager, which is itself a package. There is no overall version number., however bash --version returns GNU bash, version 4.4.23(2)-release (x86_64-pc-msys))

Problem description

When I start using MSYS2 bash in ConEmu, at start, Ctrl-R (reverse-i-search) works fine, even with long lines.

After using the session for a while, especially if I use git, something breaks, and then when I use Ctrl-R for reverse-i-search, it will find a substring in a previous command line in history - but that line will not be rendered correctly: text may be missing, and the cursor may therefore end up being placed in an empty area of text.

I cannot notice this problem when I'm using the usual MSYS2 bash shell (e.g. I run, via Win+R "Run" dialog: C:\msys64\msys2_shell.cmd), only when I run MSYS2 bash inside ConEmu - which is why I'm reporting this in ConEmu.

I have searched for similar issues, but only thing I could find that sort of resembles this problem is https://github.com/Maximus5/ConEmu/issues/1747 which is about Powershell, which is what made me post this issue as separate.

Steps to reproduce

This is kind of hard to reproduce - but I think I managed to capture the problem on video: https://www.sendspace.com/file/8wt7f4 ; I'll briefly try to go along what is shown in the video:

  1. Start a new MSYS2 bash session in ConEmu
  2. Execute echo 'a long long line here, to try and test the Ctrl-R kind of retrieval of history of command lines; just trying to have a really really really long line here, just to make sure that it breaks and all that kind of stuff, if we would like to test it' in this session
  3. Do Ctrl-R for reverse-i-search, then type test - which should find the next-to-last word in the previous command - note that the line is printed only up to ... we would like to, but the next test it is not printed, and therefore the cursor lands on an empty part of the line
    • Try Ctrl-R lookup for here - it correctly renders the whole line (including the last test it, which were not previously rendered), and correctly places the cursor near the last here in the previous command
    • Do Ctrl-R reverse-i-search for test again - the final test it of the line is again not rendered/drawn
    • Create a test git repo: mkdir aaa; cd aaa; git init ; ....
    • Add some random content to a testing.txt file, add it to the repo, commit it
    • Do Ctrl-R reverse-i-search for test again - now, if you hit Ctrl-R another time (for the entry before last fount), it shows the previous long line in full (the last test it is not dropped, as it was previously?)
    • Do some more changes in git, finish with a commit with a long message: git commit -m 'trying as really really really really really really really long long long long long ong ong commit line here, just to make sure that it breaks in the terminal'
    • Do Ctrl-R reverse-i-search for commit - works fine
    • Do Ctrl-R reverse-i-search for tem (spelling mistake for term) - line is found, but some random text from history is now also printed?!
    • Do Ctrl-R reverse-i-search for term - line is found, but it is printed in the end as ... long ong ong co m (so letter m is missing from comm, and) the rest of the line is missing - so the cursor is positioned in the empty part of the line

I have captured a screenshot from the video, showing the last issue:

2020-09-28 09-34-43 ConEmu try demo bad Ctrl-R

... and while doing that, I have noticed that the actual line found is repeated twice (?!) so that may have something to do with it.

Actual results

bash Ctrl-R reverse-i-search lookup does find the lines, but these lines have randomly missing parts of the text (and parts or lines can be duplicated), and the placement of cursor can appear in empty areas, which is extremely confusing

Expected results

bash Ctrl-R reverse-i-search does find the lines, lines are printed in full, and the cursor is placed near the corresponding word that Ctrl-R lookup found

Additional files

None

Maximus5 commented 3 years ago

As I can see from the screenshot, you are not using connector. https://conemu.github.io/en/CygwinMsysConnector.html

If that is true, than the issue should be addressed to msys itself, how it works in conhost. I think you could reproduce that by starting cmd.exe from Win+R (outside of ConEmu) and running bash.exe from here (msys version of course, be sure you are not running wsl). Also, be sure that console sizes (both visible and scrolling) are similar to what you have in ConEmu.

Maximus5 commented 3 years ago

I did a brief check and can't reproduce what you describe. Same version of bash. I'm now sure what Win10 version do you use.

But what is shown in RealConsole? Could it be that text is there, but is not visible? Try to select the text with mouse, any changes?