-
Notifications
You must be signed in to change notification settings - Fork 31
Handle very long lines #51
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
|
@karreiro Thanks for the PR. I approved the CI run, so could you please make the CI pass? Regard of the code, it looks like it does not handle the case where an error occurred in the middle of a long line. (If I am wrong, sorry.) In such a case, I think it has to add two ellipses not only at the beggining but also at the end. Another thing is a matter of taste, but I prefer to manipulate |
|
Thank you for the review, @mame! The CI should be passing now :)
That's correct. I initially thought the
That's totally fair, the code base needs to be consistent with the code style. I've made this change, and now the logic is in the Thanks again for the review! |
a07a028 to
10c69c4
Compare
|
Thanks. I think it's getting better. I actually tried your patch and noticed many things. They are all pretty minor, but I write down everthing I noticed. Should not truncate the snippet by default when STDERR is not a ttyCurrently, this patch changes the output of Maybe Opt-out of truncatingIf you set The method name
|
|
pp.rb had https://github.com/ruby/ruby/blob/d58ec11945a1f8bd26bb6d61a7e2c2f983350930/lib/pp.rb#L79-L84 Also, pp.rb falls back to |
… error highlighting to render on extremely small screens
Please, no worries at all — this level of detail is fantastic! :) I've implemented most of the suggestions in the latest commit, but I have a few minor questions to ensure the PR is nice :) --
I've made this change, and it works as expected now! --
I went ahead and implemented this, but I wonder if a slightly more intuitive API might be something like this: ErrorHighlight::DefaultFormatter.truncate
# => true
ErrorHighlight::DefaultFormatter.truncate = false
# => falseWhat do you think? --
I renamed it to --
Raising an exception seems a bit severe, so I opted to automatically adjust the limit as suggested. However, I found 7 to be too small for this context. Here's an example with 7 characters being truncated: Instead, I've set a minimum column size of 20, as it allows for more meaningful output: --
Totally agree. I've updated this so the ellipsis only appears when the last column doesn’t fit in the window. --
Good catch! We're now handling those errors, and I also agree with the decision to stop truncating in those cases. -- Thanks again for all the great input! |
|
Thank you very much! It looks awesome. Just for the case, let me test it actually in the next week.
They sound clearer to me than
Sorry, I couldn't get this meaning of this. What do you mean by "the rest of the variables"? |
Thank you very much!
Sorry, it wasn’t clear indeed. I was referring to not just variables, but also methods and constants. What I meant is that if we rename For example, I'd rename them to |
|
Sorry I'm late! I tried it and it looked good, so I merged it. Thank you so much! |
|
Do you want me to cut a release soon? Ruby 3.4 is coming soon, so we will definitely release it within 2 months. If it is better to release it earlier for Ruby 3.3 or before, I will do it. |
|
Oh, I forgot about name consistency. I don't really care about the names of local variables. If I wrote it myself, I would even have used a single letter variable like Come to think of it, I wonder if |
|
I didn't like |
|
Thanks so much for all the feedback and improvements, @mame! Ruby 3.4 looks good! It'll be awesome to see this enhancement there :)
I agree that And from the perspective of truncation, I've made that change here: |
Fixes #5
This PR updates the
ErrorHighlight::DefaultFormatterto handle long lines. We're now identifying the number of columns in the terminal so that we can truncate the snippet and present it on a single line.Before

After
