-
-
Notifications
You must be signed in to change notification settings - Fork 299
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
Allow tabs for the indentation added by code actions. #684
Allow tabs for the indentation added by code actions. #684
Conversation
…tools#673). The previous implementation always assumed spaces for indentation. But in stage2 code may contain tabs for indentation as well.
if tabs are allowed by stage2 then its a bug, theyre supposed to be a hard error |
https://github.com/ziglang/zig/wiki/FAQ#why-does-zig-force-me-to-use-spaces-instead-of-tabs
|
the spec aside, wouldn't this mean compilation errors for the many who still use stage1 ? |
stage1 isnt a concern since stage2 is now the default compiler. tabs do not align to |
Andrew stated in #544: "The Zig language accepts hard tabs[...]. The self-hosted compiler implements the Zig language correctly; accepting hard tabs [...]" So I think it is safe to assumes that tabs for indentation will be allowed and used by some in the foreseeable future. While @nullptrdevs |
I'll weigh in here; I frankly could not care less about what indentation someone uses in Zig. If this improves user experience then I'm all good with it. |
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.
I really dislike the approach taken here; wouldn't the line slice be guaranteed to simply be the tabs needed for indentation if your document's indentation is set to tabs removing the need for the additional_indent
hack? From a cursory glance I believe a solution that like should be effective. :)
Yeah I don't really like it either. But in this case I think it is needed: fn(unusedVar: xy) void {
_ = unusedVar; // ← needs more indentation then the previous line. I could put this inside a function that returns the full indentation, but that would require additional allocations. |
That does make sense.. what if the last param of createDiscardText be a bool, do_add_block_indent or block_indent_needed |
Yeah, I thought about that, but to figure out if tabs are used I need the entire file(The function in question might be in file scope, without indentation, so I cannot determine if tabs are used from just the indentation of the function declaration). So in that case I would need two new parameters instead of one. But now that I think about it, I might just pass the builder in there instead of passing only the allocator. I also noticed another issue, that I'll try to fix:
Even worse for |
…) and move the indentation code inside `createDiscardText()`.
Done. |
Please resolve conflicts :) |
I fixed the merge conflicts like a week ago. I'm guessing you didn't get a notification for that? |
Sorry in the middle of midterms and work, LGTM. |
I just tested #673 in my codebase and the indentation was messed up:
Before:
After:
The thing is: My codebase uses tabs (which is allowed as of stage2).
Normally I would have just made an issue about it, but since this is quite easy to fix, I thought I might just do it myself.