-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Groups of spaces in scripts automatically changing into tabs/indentation #78657
Comments
This comment was marked as outdated.
This comment was marked as outdated.
This is handled by settings indeed, and desired feature, not a bug, and follows the code style
I am not convinced their response was based on the exact description as the way you phrased it on the QA page is very different from how it was phrased here, the first image on the QA page also does not work |
default-behaviour-and-overriding-it could mention the default WS and how to change it. |
I don't have a horse in this race (since I don't use script templates, as mentioned in the linked Q&A thread), but this feels strange to me. In my view, an indent refers to some amount of space added ahead of a line (or block) of text to move it away from the margin. I don't see how (or why) indent settings should make automatic adjustments to spacing within a line of text - which is what's happening here. So, to me, it's perfectly valid for indent settings to make adjustments to this, for example:
However, to convert between spaces and tabs within the line seems a bit over-zealous... So, while automated modifications to leading and trailing white-space seems perfectly valid (and even expected when using most programmer's editors), I don't think I've ever seen an editor mess with inner line spacing. Is this really intentional? |
My bad, OP didn't add any description to show this behaviour in any screenshots I saw, and was talking about "indentation" which isn't at the end of a line, hence my confusion That is a bit more complex yes |
Yes, this is clearly a bug. |
Note that this does not happen when just converting spaces normally, but must be somehow related to the templates, will look into |
This is due to this part: godot/editor/script_create_dialog.cpp Lines 863 to 910 in 3710f06
Will investigate a fix |
Please open a separate issue if one doesn't exist, this is a separate area of the code |
Yeah, those two |
Working on a new fix based on the convert indent code, will update if I solve it |
Could we somehow have same code for both cases? |
Not really they're in completely different part of the engine, this is handled in |
WDYT is the automatic Indentation meant for here. Should it just call the conversion function for editor default WS settings? |
There isn't a default conversion function to call, The template code converts tabs and spaces to |
Fix for this specific bug open, if there's an issue in "Auto Indent" please open a dedicated issue to track it |
Hey everyone, I just woke up to all your messages! Thank you so much for hopping on this so quickly. I apologize for not including a visual in my post of what happens, I figured my little issue description and the steps to reproduce explained that but I can see that I should have had both. I've updated it to be more clear (hopefully)! I am a bit confused as the conversation has gone up and down a bit, with some saying it's a bug, others saying it's something else, and others saying to open a new issue for this for some reason...can I please just get a single explanation of what the next steps are and what is truly happening with my code here? Why it's just now doing this when Godot 3.X never had the issue? Thanks again!! |
No new issue for a different bug, never said anything about a separate issue for this bug, and the code has massively changed since 3.x |
Hmm ok, sorry if you feel like you've explained but I'm still confused - is my "issue" going to be "fixed" somehow? Should I expect to be able to use my template as intended in later releases? |
It is, there's a PR open for it right now that will close it, what I was talking as a different issue is the "Auto Indent" issue that I mentioned above was a different issue, I'm sorry for causing confusion |
Thanks a lot! You all rock. I've never submitted an issue here before, Q&A has always met my needs. Should I expect a message here when the fix is released or something? Or should I just manually check when the next few patches roll out? |
This will close when this is solved, will hopefully be in 4.1 Edit: Scheduled for 4.2, hopefully with a future cherry pick for some 4.1.x version |
UPDATE: THIS IS RESOLVED WITH GODOT 4.2.
Godot version
4.0.3.stable
System information
Windows 11, ask for more info if needed, I'm not sure what else would be needed here.
Issue description
Issue also asked about on Godot Q&A (currently unresolved): https://ask.godotengine.org/155740/godot-automatically-creating-tabs-script-template-how-that
I have a script template that I use for all my scripts. In this template, I have an instance of a long line of spaces leading to a comment (this is my commenting method of choice, putting all comments on the right). Looks like (without underscores, would be spaces):
my code _ _ _ _ _ _ _ _ _ _ _ # my comment
It worked perfectly in prior versions, though after switching to Godot 4 it has started converting my groups of spaces into tabs. It now looks like this (with the indent carrots), despite me only including spaces there in my .gd file:
my code > > > > > > > > > # my comment
I cannot find a way to disable this "feature" and believe it to truly be a bug. Mr. J. Godfrey (a Godot contributor/Q&A admin I think?) believes so as well. I have taken a look at the indentation section of the editor settings but this is a different feature. I like tabs for indents, and am not trying to change that. I just don't want Godot to auto-change my spaces into indents when it sees a group of them. I understand others may, so I'm proposing there is an option created for that (or please inform me of which one it is if it exists). When I create/edit this template in Notepad, I'm able to verify that it is indeed just normal spaces.
Steps to reproduce
Go to this link and download the script template I created (this program won't let me attach a .gd for some reason):
https://drive.google.com/file/d/1oXPKAn_3DulkF2oIFNYTFV3QKuNKdGz-/view?usp=sharing
Load it into a folder called "Objects" within your script templates folder (you may need to create this folder, found at Godot master folder location...Godot Engine\editor_data\script_templates\
Create a new script in Godot 4.0.3.stable and select this file as the template. You may need to create it on a node, type shouldn't matter.
Open the new script and see that the "extends" line has a bunch of tab indents when it should just be spaces.
Minimal reproduction project
N/A, this is trivial
The text was updated successfully, but these errors were encountered: