Skip to content
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

Convert clipboard indentation on paste to match editor settings #3525

Open
Tracked by #40488
akien-mga opened this issue May 31, 2018 · 5 comments
Open
Tracked by #40488

Convert clipboard indentation on paste to match editor settings #3525

akien-mga opened this issue May 31, 2018 · 5 comments

Comments

@akien-mga
Copy link
Member

Godot currently lets you define your indentation preferences via the editor settings:
screenshot_20180531_090703

When you paste code from projects using different conventions (e.g. the official docs where code blocks are indented with 4-spaces to match the usual Sphinx convention), you can easily introduce indentation mismatch and syntax errors in your code.

Most IDEs have an option to convert indentation of the code in the clipboard when you paste it in the script editor. We currently have such an option to convert indentation of the whole file on save, but not of the pasted code on paste. This should be added.

The feature should respect both:

  • the indentation settings defined in the editor settings
  • the code context: when pasting code in an already-indented block, the whole paste block should be re-indented accordingly.

This conversion step can be done as a complex operation after the paste, so that Undo still lets you go back to the un-converted paste if need be.


Note: This issue is not to discuss what the default indentation settings should be, it's strictly about implementing this basic feature most IDEs have to convert indentation on paste to match what the user wants to have.

@chucklepie
Copy link

chucklepie commented Jul 10, 2019

I'd just like to say that there is much pain in copying clipboard data from the Godot site and other places into Godot due to tab/space conflict in the same block.

To fix almost all these issues, why not simply change the default 'type' to be SPACES and not TABS (editor settings/indent)? Using SPACES as the option still lets you tab and shift-tab, automatically converting tabs to 4 spaces and shift-tab to go back 4 spaces.

This will fix almost all website copy/paste issues (like Godot tutorials.). I cannot think of a single drawback.

@Calinou
Copy link
Member

Calinou commented Jul 10, 2019

@chucklepie As stated in OP:

Note: This issue is not to discuss what the default indentation settings should be, it's strictly about implementing this basic feature most IDEs have to convert indentation on paste to match what the user wants to have.

Sorry, but we've settled on tabs in GDScript; this isn't subject to change.

@akien-mga
Copy link
Member Author

This will fix almost all website copy/paste issues (like Godot tutorials.). I cannot think of a single drawback.

This will not fix the issue if what you're pasting is tab-indented code instead of 4 spaces-indented code. It might be a bit less frequent, since the official docs use 4 spaces for indentation, but you would still get the same issue further down the road when you copy paste code from another source using tabs for indentation.

@akien-mga
Copy link
Member Author

And for those who missed it, there's a pending PR to fix this issue already: godotengine/godot#28561.

@akien-mga akien-mga transferred this issue from godotengine/godot Nov 10, 2021
@akien-mga
Copy link
Member Author

Note: Old issue transferred from the main engine repo, so OP doesn't follow the proposals template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants