Skip to content

Apply editor.indent preference #6129

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

Merged
merged 3 commits into from
Apr 13, 2017
Merged

Conversation

facchinm
Copy link
Member

Solves #6128

@mastrolinux mastrolinux added the in progress Work on this item is in progress label Mar 27, 2017
@facchinm facchinm added this to the Release 1.8.3 milestone Mar 27, 2017
@bombasticbob
Copy link

tested the linux64 version. it now honors the true/false state of the 'editor.indent' setting for indenting. however, the unwanted behavior of adding a '}' for me when I type '{' is still there.

Thank you for fixing this part of the issue. I have noted that the '{' '}' "autocomplete" behavior is no longer directly associated with indenting. It happens whether or not indenting is enabled.

I shall add a new issue to use a 'preferences.txt' string to disable the unwanted (irritating) behavior, and reference these issues as part of it.

@bombasticbob
Copy link

related to this issue, I found the code that inserts the ending curly brace, see latest comment added to #6132 (with recommended change)

@@ -148,6 +148,7 @@ private SketchTextArea createTextArea(RSyntaxDocument document)
textArea.setMarginLineEnabled(false);
textArea.setCodeFoldingEnabled(PreferencesData.getBoolean("editor.code_folding"));
textArea.setAutoIndentEnabled(PreferencesData.getBoolean("editor.indent"));
textArea.setCloseCurlyBraces(PreferencesData.getBoolean("editor.indent"));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this be a separate preference? I personally dislike autocompletion, but I do want (same-level) auto indent (i.e. pressing enter preserves the indentation of the previous line, it should not increase indentation after a { for me).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, it should be moved to its own preference. I added it this way to check if the functionality was ok and provide a build with it

@bombasticbob
Copy link

@facchinm
@matthijskooijman

Thanks for the activity on this. Yes, I'm in total agreement with your earlier comments about making these two functionalities separate. Since the forum post from a couple of years ago (mentioned at the beginning) suggested that getting rid of auto-indent also got rid of auto-closing-brace, I had to weigh getting rid of something I want (auto-indent) against getting rid of something I really do not want (auto-closing-brace). Having the two settings instead (i.e. #6132) would be the best overall fix for this.

So thanks for the mention. Also thanks for testing how it can be done.

@bombasticbob
Copy link

bombasticbob commented Apr 5, 2017

Here's a patch file that I have created based on a 'git clone' I did on the repository. It includes the change that fixes 'indent' (noted above) as well as adding 'editor.autocomplete' (issue #6132). I tested it and it works perfectly. It requires manually editing the local 'preferences.txt' to turn off the feature, but that's fine with me and probably everyone who wants this feature on by default.

issue_6132.patch.txt

@bombasticbob
Copy link

@facchinm

please incorporate #6155 as well. then at least 3 additional people would be happier (and most likely many others).

@facchinm facchinm force-pushed the editor_indent_pref branch from 180a80e to b22c1bf Compare April 10, 2017 13:31
@facchinm facchinm force-pushed the editor_indent_pref branch from b22c1bf to 6094788 Compare April 10, 2017 13:34
@cmaglie
Copy link
Member

cmaglie commented Apr 11, 2017

@bombasticbob
the option editor.autocomplete, as it is now, disables "auto close braces" but not "auto indent", while I expect it to override both (even if editor.indent is true).

Anyway, the editing-aids are just "auto indent" and "auto close braces" and IMHO is too early to think about an option to disable the aids altogether, I'd add such option later when/if more editing-aids are added.

So here my proposal:

  • Change editor.autocomplete (that seems too generic to me) to editor.auto_close_braces and merge this PR as is
  • Postpone the option to disable all editing-aids to a future PR when more editing-aids are added

@bombasticbob
Copy link

@cmaglie

changing the text of the setting to 'auto_close_braces' is ok with me. I just want a way to control the behavior. I'm happy that the only question is what actual name to use [something I had already guessed might happen].

@cmaglie cmaglie merged commit 00c1a3b into arduino:master Apr 13, 2017
@cmaglie cmaglie deleted the editor_indent_pref branch April 13, 2017 09:38
@mastrolinux mastrolinux removed the in progress Work on this item is in progress label Apr 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants