-
-
Notifications
You must be signed in to change notification settings - Fork 121
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
Indentation with tabs throws off labels #87
Comments
I'm not sure if there's much we can actually do about this, but I know that #73 was filed before and a PR was sent in. And now we have a feature that lets you configure how wide tab characters should be? Does that solve your issue? |
Ooh that’s exactly the solution that I would have proposed: An option to convert tabs to spaces of a given width. Brilliant. Thank you. |
It's great to have this option, however I think it's still an issue that the default behavior is broken for source code indented with tabs. Relying on users of The easiest option here would be to make For example, printing the following text to a terminal
produces output that looks like this
while replacing tab characters with spaces looks like this
The alternate option, which doesn't have these downsides, would be to use actual tab characters to align the labels. Doing this correctly sounds somewhat tricky to get right. I'd be up for writing a PR for either of these, and would probably prefer the latter option, but there's definitely a higher maintenance burden for that, and I don't want to implement it if the maintainers would rather go for the simpler option. |
Thinking about it... I think it might not actually be that tricky to use tab characters to align the start of those labels. You "just" need to scan the prevline (which iirc is already accessible where you would need it), count the number of tabs, and add that many tabs + the remaining characters in spaces, and everything should be in the right place? The trickier part, I think, is getting the underline itself to align properly. I think I'd definitely rather have the second option here, imo, and I would love a PR for this. Happy to help if you have any questions about the code. And while you're in there, if you can come up with any brilliant ideas to address #97, even better (since this is actually related to that, tbh) |
I think it's a little bit more complicated than counting the number of tabs and sticking spaces on the end, since that will still produce different results if the tabs don't occur on tabstop boundaries. For example:
To align a label to the #97 looks like it already has a fix merged. Is it still an issue? Also yeah, no good ideas about how to handle the underline yet... I'll probably have time to work on this later today, but not sure how hard it will actually be to get right :). |
The fix to #97 wasn't complete. It was only for fixing the numbers in the "narratable" handler that just prints out a text explanation. It still needs to be done for the graphical handler. |
Fixes: zkat#87 BREAKING CHANGE: Tabs are always expanded to spaces by the graphical handler, and `tab_width` now defaults to 4. Instead of replacing every tab with a fixed number of spaces, spaces are used to align to the next tabstop. `tab_width` controls the space between tabstops rather than the fixed width of each tab character.
…rs and tabs (#202) Fixes: #97 Fixes: #87 Tabs are always expanded to spaces by the graphical handler, and `tab_width` now defaults to 4. Instead of replacing every tab with a fixed number of spaces, spaces are used to align to the next tabstop. `tab_width` controls the space between tabstops rather than the fixed width of each tab character. Co-authored-by: Benjamin Lee <benjamin@computer.surgery>
(Sorry to not provide a proper repro. I’ll provide one later if you want, just wanted to get the issue opened before I forget).
If I have code indented with tabs, it seems that something goes wrong with the labelled spans:
If I instead indent the code with spaces, it looks correct:
I’m assuming that this might be due to terminal configuration how to display tabs?
The text was updated successfully, but these errors were encountered: