Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Fixes #31 and #41 - #43

Merged
kevinsawicki merged 3 commits into
atom:masterfrom
svanharmelen:b-fix-indents
May 11, 2015
Merged

kevinsawicki merged 3 commits into
atom:masterfrom
svanharmelen:b-fix-indents

Conversation

@svanharmelen

Copy link
Copy Markdown
Contributor

I know at least two [1][2] corner cases which are still not 100% after adding this fix. But those corner cases require a tweak to Atom itself. This has to do with the need for an option to decrease the indent level
based on the previous line, which currently is not supported in Atom.

Take this use case:

s := fmt.Sprint(“some” +
  “thing”)
  fmt.Print(s)

[1] The indentation for this is now done correctly for the first line, but only if you press enter after the + sign while the statement is already complete (so "thing") is on the same line already. But if you type this in (which is of course expected behaviour) and while typing you hit enter right after the + sign with only a ) behind the cursor, it will not indent.

This is correct as a single ) on a line is closing an earlier opened ( and should have a decreased indent level assuming there are indented lines in between. But then as soon as you start typing "thing" it should indent, because it no longer is a single ). Atom currently has no way to do this. It can do this for decreasing indents (like you can see with case in a switch statement, but not for increasing indents.

[2] Next to that the last line should have a decreased indent level. But again given the current options Atom give us there is no way to do this as decreasing the indent should be based on the previous line instead of the current.

Will look into Atom core to see if I can extend the possibilities so we can also fix the last corner cases.

Nevertheless I would like to get this one in before that, as it fixes a few open issues and gives others the option to test and maybe extend (if they find new corner cases) the regexes.

Sander van Harmelen added 2 commits May 10, 2015 13:32
I know at least two corner cases which are still not 100% after adding
this fix. But those corner cases require a tweak to Atom itself. This
has to do with the need for an option to decrease the indent level
based on the previous line, which currently is not supported in Atom.

Take this use case:

```
s := fmt.Sprint(“some” +
  “thing”)
  fmt.Print(s)
```

The indentation for this is now done correctly for the first line, but
the last line should have a decreased indent level. Given the current
options Atom give us, it seems to me there is no way to fix this
currently.

Will look into Atom core to see if I can extend the possibilities so we
can also fix the last corner cases.

Nevertheless I would like to get this one in before that, as it fixes a
few open issues and gives others the option to test and maybe extend
(if they find new corner cases) the regexes.
Possibly prevents some corner cases as it are more strict matches.
After more testing this isn’t a good one to add until the Atom
internals are a bit better for this type of use case.
kevinsawicki added a commit that referenced this pull request May 11, 2015
@kevinsawicki
kevinsawicki merged commit 5f177a5 into atom:master May 11, 2015
@kevinsawicki

Copy link
Copy Markdown
Contributor

Thanks for adding these

@svanharmelen
svanharmelen deleted the b-fix-indents branch May 11, 2015 16:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants