Dyalog / ride

Cross-platform IDE for Dyalog APL
https://dyalog.github.io/ride
MIT License
204 stars 31 forks source link

Incorrect editor indentation #158

Closed JohnScholes closed 7 years ago

JohnScholes commented 7 years ago

Describe the issue you are having

If preferences->code-> "Indent contents when an editor is opened" is checked, some lines are incorrectly indented. Plus, the editor's usually excellent predictive indentation gets it wrong if the last line ended }{.

Did you connect to an already running interpreter or start the interpreter from RIDE?

Start an interpreter

How do you reproduce the issue?

Ensure preferences->code-> "Indent contents when an editor is opened" is checked then open an edit window on this function:

foo←{
    {
        1+⍵}{
        1+⍵}{
        1+⍵}⍵
}

It is wrongly indented like this:

foo←{
    {
        1+⍵}{
            1+⍵}{
                1+⍵}⍵
}

For a larger example:

      )xload min
... saved ...
      )ed combo

Paste the contents of Help → About (Shift+F1)

IDE: Version: 4.0.2801 Platform: MacIntel Date: 2017-05-05 15:12:33 +0100 Git commit: 1f2c48118cb3919c6b2fc48a93df4b84fbfbbf95 Preferences:{ "autocompletion":"0", "kbdLocale":"en_US_Mac", "lineNums":"0", "pfkeys":"[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\")reset)save\",\"\",\"\"]", "squiggleTips":"0", "valueTips":"0", "zoom":"5" }

Interpreter: Version: 16.0.29853 Platform: Mac-64 Edition: Unicode/64 Date: May 6 2017 at 01:17:57

e9gille commented 7 years ago

When the editor is opened it receives the formatted body of the function from the interpreter. I'm not sure what the value is of this feature in the first place. Is there a use case for keeping it in?

JohnScholes commented 7 years ago

"Indent contents when an editor is opened" is equivalent to the ODE editor's "AutoFormat Functions" setting, which is ON by default in the ODE.

e9gille commented 7 years ago

Is this specifically to deal with scripts? Normal functions get reformatted on fix anyway, or is that a setting in the interpreter?

JohnScholes commented 7 years ago

I don't know about scripts. Auto-reformatting of (normal) functions is a setting: ODE: "Options->Configure->Trace/Edit->AutoFormat Functions" Ride: "Preferences->Code->Indent contents when an editor is opened" The problem is not that it happens but that Ride gets the indentation level wrong, as per the above examples and code such as http://dfns.dyalog.com/c_morse.htm

e9gille commented 7 years ago

Yes, I agree that RIDE gets it wrong and I can see why (now I just need to think of the solution). So enabling autoformat in ODE causes functions to be formatted when you fix them from RIDE, irrespective of the settings in RIDE. I had autoformat enabled in ODE which is why I questioned the benefit of the RIDE setting.