-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Correctly handle ANSI Escape Codes in ElideMiddle, fix #713 #2428
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
Conversation
5c960f9
to
5c253c4
Compare
Ha, looking at your diff I think I just had it wrong. EIther an off-by-one or maybe a rounding mistake in the |
elide_size rounds down and if the width is even (let's say 12), this means that the result would be:
To fix this we'd have to show another character either in the beginning or the end (my preference). I think this only works with an explicit If you think this was unintentional I would have a go at it in another PR :) |
5c253c4
to
7454b0b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to work here. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, playing around with it more, it seems to not work quite right. Here is a copy of the tmux
buffer on a pane that is narrow enough to require elision (executed from with nvim
, but the elision code is definitely involved here).
`tmux` buffer state
[-Wunused-variable] 3577 | FlagClassification cls = FlagClassification::PrivateFlag; [-Wunused-variable] 3582 | FlagClassification cls = FlagClassification::LocationFlag; [-Wunused-variable] 3583 | FlagKind kind = FlagKind::BuildSystem; 0-5->13/[email protected]] Linking CXX executable bin/ctest | ^~~~ 0-4->14/[email protected]] Linking CXX executable bin/cmake [15-1->2/[email protected]] Linking CXX static library Source/libCMakeLib.a 0-3->15/[email protected]] Linking CXX executable bin/ccmake [5-10->3/[email protected]] Linking CXX executable Tests/CMakeLib/testAffinity 0-2->16/[email protected]] Linking CXX executable bin/ctresalloc [4-10->4/[email protected]] Linking CXX executable Tests/CMakeLib/testUVProcessChainHelper 0-1->17/[email protected]] Linking CXX executable Tests/CMakeLib/CMakeLibTests [3-10->5/[email protected]] Linking CXX executable Tests/CMakeLib/runcompilecommands [2-10->6/[email protected]] Linking CXX executable Tests/CMakeLib/testDebuggerNamedPipe
[1-10->7/[email protected]] Linking CXX executable Tests/CMakeLib/PseudoMemcheck/valgrind
[0-10->8/[email protected]] Linking CXX executable Tests/CMakeLib/PseudoMemcheck/purify
[0-9->9/[email protected]] Linking CXX executable Tests/CMakeLib/PseudoMemcheck/cuda-memcheck
[0-8->10/[email protected]] Linking CXX executable Tests/CMakeLib/PseudoMemcheck/memcheck_fail
[0-7->11/[email protected]] Linking CXX executable Tests/CMakeLib/PseudoMemcheck/BC
[0-6->12/[email protected]] Linking CXX executable bin/cpack
[0-5->13/[email protected]] Linking CXX executable bin/ctest
[0-4->14/[email protected]] Linking CXX executable bin/cmake
[0-3->15/[email protected]] Linking CXX executable bin/ccmake
[0-2->16/[email protected]] Linking CXX executable bin/ctresalloc
[0-1->17/[email protected]] Linking CXX executable Tests/CMakeLib/CMakeLibTests
It looks like newlines are being truncated somewhere.
I'll keep digging to see if I can find some other cause here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to be a Neovim thing; I've not seen anything wrong in terminals.
I find it a bit weird, that even in the old implementation, passing 10 will result in a string of size 9. Isn't this a bug? @evmar do you remember if there was a reason for that? I think d82e806 is the first commit which adds the 10 -> 9 unit test.
Maybe that should be fixed in the old implementation first.
Regarding this implementation: Using std::regex might be too slow, but it's a start and can be used as a reference implementation.