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

Indentation updates - #204

Merged
winstliu merged 5 commits into
atom:masterfrom
kbrose:indentation-updates
Jul 13, 2017
Merged

winstliu merged 5 commits into
atom:masterfrom
kbrose:indentation-updates

Conversation

@kbrose

@kbrose kbrose commented Jul 7, 2017 •

Copy link
Copy Markdown
Contributor

Description of the Change

Alternate Designs

None.

Benefits

Better support for the Python language.

Possible Drawbacks

Applicable Issues

kbrose added 3 commits July 7, 2017 00:10
This is the technically correct regex to prevent dedenting the current
line on things like in-line else expressions, but unfortunately
the regex is already matched before anything can be done about it :(

Leaving it in as is in the hopes that it will be useful someday.
expect(decreaseIndentRegex.testSync(' elif this_var == that_var')).toBeFalsy()
expect(decreaseIndentRegex.testSync('else')).toBeFalsy()
expect(decreaseIndentRegex.testSync(' "finally:"')).toBeFalsy()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔥 empty line

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed

@winstliu

Copy link
Copy Markdown
Contributor

Nice! Regexes look good and 💯 on that spec file.

@kbrose

kbrose commented Jul 13, 2017

Copy link
Copy Markdown
Contributor Author

Thanks for reviewing @50Wliu. Let me know what else I can do.

@winstliu
winstliu merged commit 3141b00 into atom:master Jul 13, 2017
@kbrose
kbrose deleted the indentation-updates branch July 13, 2017 03:09
@Sherlock-Holo

Copy link
Copy Markdown

It is a very bad feature for me!!!! There must be some people like me want to turn off this feature. How do I do to turn off this feature?

@Sherlock-Holo

Copy link
Copy Markdown

when I try to write:

def main():
    if True:
        return 1
    else:
        return 2

the else will dedent, it is a bad behaviour.

@kbrose

kbrose commented Sep 19, 2017

Copy link
Copy Markdown
Contributor Author

Sorry to hear it doesn't work for you, but I think calling it "a very bad feature" is a bit of a stretch. I've been using it for the past few months and while it is by no means perfect, it has definitely had a net positive effect on the amount of typing I have to do to get correct indentations in Atom. (I could just as easily construct an example that did not correctly dedent before, but now does correctly dedent, and say that the old behavior was "a bad behavior". Trying to parse a complete language with regexes will always have trade-offs.)

Still, if it doesn't work for you then it should be fairly straightforward to submit a PR which makes it an option in language-python. In the meantime, you could comment out the line

'decreaseNextIndentPattern': '^\\s*(pass|return|yield|continue|break|raise)\\b.*$'

from the effected file then you should stop seeing the behavior.

@Sherlock-Holo

Copy link
Copy Markdown

@kbrose Thanks for your advice, unfortunately I can't find which file I should modify. Could you tell me more about it?

@Hanzhizheng

Copy link
Copy Markdown
def f(n,lookup):
    if n==0 or n==1:
        lookup[n]=n
    if lookup[n] is None:
        lookup[n]=f(n-1,lookup=)+f(n-2,lookup=)
    return lookup[n]

the auto '=' in params

def x(n):
    if n==1:
        return n

when coding n you type 'tab' it comes out the list tochoice like this: v n, the tab doesn't work.

def x(n):
    if n==1:
        return n
else:

type ':' the else will auto move to the head.

@Sherlock-Holo

Sherlock-Holo commented Oct 9, 2017 via email

Copy link
Copy Markdown

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants