-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
"Colour wrapping" #2161
Comments
This feels more like a rendering bug than a problem with ripgrep. Regardless, I'm not a Windows user. Someone else will have to debug this. |
I'm on windows, so I can look into this. That said, I'm also not an expert on Windows. My guess would be this has something to do with the way the Windows console writes wrapped lines; it looks to me like what happened was that after writing the |
It seems like this issue is known It may be related to these resizing bugs:
Clearing the remainder of the line when writing a newline (per JanDeDobbeleer/oh-my-posh#65) will apparently produce the correct behavior. @BurntSushi: Apparently, Windows already has VT100 (ANSI) escape sequence support. They still require accessing the Windows console API to enable, but if I'm reading the docs correctly, they should work the same way any other OS does. I think they probably exist because of the Linux subsystem in Windows 10. |
@gvanem Sorry for late reply, but the bug seems to be present in any shell on Windows, so I think you're correct. @BurntSushi What would you say the best way to insert a line clear just before a newline is written in the output functions? I think I've found a place but I can't say for sure. I've hit another snag, too: Windows API doesn't offer the equivalent to "clear to remainder of line," only VT mode does, so I would need to manually change the remainder of the line on wrapping. I'm going to see about forking |
To be honest, I just don't really have the bandwidth right now to dig into this. The Windows console API is indeed quite limited. On the other hand, it's been quite some time (years now) since Windows supported ANSI color escapes. So if you fix it for ANSI escapes, that might be enough. The right place for this to go is indeed probably in Another option here, honestly, is to not fix it. This really seems like a bug in how Windows consoles handle this stuff to me. But if the fix is to do a search for |
The Short Version is that Microsoft says:
I didn't see this cleary summarized, so I added extra information so that they may link to it. place. Windows
|
Name | xterm compatible? |
---|---|
Windows Console Host |
Yes for Windows 10 and higher |
Windows Terminal |
Yes Supports 24bit color and utf8 supportIs the default in win11 |
Quotes from the Documentation
-
-
-
Over the course of 2022, we are planning to make Windows Terminal the default experience on Windows 11 devices, Windows terminal is the new default console in windows11
-
Applications that use the GetConsoleScreenBufferInfo family of APIs to retrieve the active console colors in Win32 format and then attempt to transform them into cross-platform VT sequences (for example, by transforming
BACKGROUND_RED
to\x1b[41m
) may interfere with Terminal's ability to detect what background color the application is attempting to use. -
Application developers are encouraged to choose either Windows API functions or VT sequences for adjusting colors and not attempt to mix them.
That red one sounds like @gvanem OP's bug, and fits with the StackOverflow threads about bugs when resizing the window.
-
Future planning and
pseudoconsole
: There are no plans to remove the Windows console APIs from the platform. -
On the contrary, the
Windows Console host
has provided thepseudoconsole
technology to translate existing Windows command-line application calls intovirtual terminal sequences
and forward them to another hosting environment remotely or across platforms
@gskt17 should work like any other platform
The last link had a little bit on the origin
issues
Windows users pay. (They already pay a fair amount. ripgrep is generally much quicker on Linux/macOS in my experience.)
Fairly recently -- maybe the last 5?, 10? years -- Microsoft has turned around. Instead of competing, they started integrating open source projects. Powershell being both open source and cross platform is pretty neat. ripgrep works great on windows.
I agree it works great. I'm speaking from experience benchmarking equivalent corpora with similar CPUs. Windows tends to be quite a bit slower. It has been only a couple years since I've performed said benchmarks. And I do not claim to know why there is a difference, although I have a variety of guesses. Windows requires additional work in some cases with interacting with its system APIs (not console APIs). |
This issue does not appear actionable on my end. |
What version of ripgrep are you using?
ripgrep 13.0.0, -SIMD -AVX (compiled)
How did you install ripgrep?
Built it myself by
cargo build --all --release --features pcre2
What operating system are you using ripgrep on?
Win-10, 21H1, ver. 19043.1586.
Describe your bug.
As part of a
pygrep.bat
file I use RipGrep like:With the Windows console width set to 120, a command like
pygrep.bat IP2Location
, shows this:the red colour bleeds over to the next line marking a non-match.
What is the expected behaviour?
With the WinConsole width set to e.g. 130, there is no problem. A
cls & pygrep.bat IP2Location
, shows this:In lack of a better description, I named this "Colour wrapping". I've no idea what's the real issue here.
But this depends on which Y-position the .bat-file was invoked on. It's as if a 1 line scroll when
"match:bg:red"
is ineffect causes this bleeding. Since if I increase the console height to avoid a scroll, then there's no bleeding.
PS. I wrote that
netstat.py
script using psutil.The text was updated successfully, but these errors were encountered: