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

Option to permanently disable parinfer, or issue warning #1369

Closed
mtruyens opened this issue Apr 20, 2016 · 3 comments
Closed

Option to permanently disable parinfer, or issue warning #1369

mtruyens opened this issue Apr 20, 2016 · 3 comments
Labels
released Marks issues which have had the fixes released in a stable build
Milestone

Comments

@mtruyens
Copy link

It has occurred already twice on me that I accidentally enabled Parinfer mode, and then noticed several hours later that one of the CLJ-files opened at the time Parinfer was enabled, suddenly did not compile anymore, because Parinfer altered some parens that were not correctly indented for Parinfer mode.

This is quite dangerous: while most of my files are correctly indented for Parinfer, not all of them are.

I would suggest to:

  • either introduce an option to permanently disable parinfer, so that you cannot accidentally enable it when toggling between "structural editing off" and paredit;
  • ask explicit permission on a file-by-file basis for re-indenting a file when enabling parinfer.

Or did I miss something?

@cursive-ide cursive-ide added this to the 1.2.5 milestone Apr 20, 2016
@cursive-ide
Copy link
Owner

Yes, this is a bad problem I'm going to fix for the next release. There are two issues here: first, even if parinfer reindents code, it should not break it since it should run paren mode to correct the indentation first. Then at worst, you'll get some spurious changes in your files.

However that's problematic too, so I'm going to try to modify parinfer so it only does the indentation correction on first change, rather than on file open. Then at least toggling through parinfer mode won't change anything, and being in parinfer mode won't change files just by looking at them.

I also considered having the toggle switch between structural editing being off totally and the mode (parinfer or paredit) that you have selected, instead of cycling through the three. However it's problematic when the user toggles when structural editing mode is off. I'd have to remember the previous mode that the user selected in that case. It would also mean that there would be no way to get from parinfer to paredit and back without using the status bar toggle or the config pane.

@blakelivingston
Copy link

blakelivingston commented Apr 21, 2016

+1 to this issue. My editing workflow has been pretty severely impacted from the spurious changes that occur when I flip past parinfer to no-structural for small changes. I like the idea of breaking down structural on/off structural-style=paredit/parinfer(indent|paren). Reformatting on first edit also sounds like good business.

@cursive-ide
Copy link
Owner

Ok, I've fixed the bug where toggling the structural style would break code - that wasn't running paren mode to correct indentation when entering parinfer mode, which would break code.

I've investigated making parinfer modify the indentation on first change, but that's difficult. I thought I could do it by hooking into the action system and making the change on the first action, or before typing. However since in IntelliJ everything is an action, it would be triggered on (for example) toggling the style again, switching to a new file, etc - there's no good way to distinguish actions which will modify the document.

So I've added some config under Editor→General→Smart Keys which allows you to select which of the 3 modes the toggle action should cycle through. So you can set it to just Off and Paredit and it will switch between them, or Off and Parinfer, or Parinfer and Paredit, or leave all 3 selected and it will cycle through them all as it does now.

@cursive-ide cursive-ide added the released Marks issues which have had the fixes released in a stable build label Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released Marks issues which have had the fixes released in a stable build
Projects
None yet
Development

No branches or pull requests

3 participants