After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 742921 - Python auto-indentation oddity
Python auto-indentation oddity
Status: RESOLVED FIXED
Product: gnome-builder
Classification: Other
Component: editor
unspecified
Other Linux
: Normal normal
: ---
Assigned To: GNOME Builder Maintainers
GNOME Builder Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-01-14 14:37 UTC by Elad Alfassa
Modified: 2015-01-20 04:33 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
python: fix indent after function call statement (1.50 KB, patch)
2015-01-20 04:31 UTC, Christian Hergert
committed Details | Review

Description Elad Alfassa 2015-01-14 14:37:45 UTC
I found a weird problem with the python auto-indentation in Builder.

Assume this sample code:

def foo():
    ret = "foo".format(bar,len(baz))

If you press enter after the closing ) of the .format, the next line will begin on column 24 instead of in column 5 like it should.
Comment 1 Christian Hergert 2015-01-14 20:55:53 UTC
I broke this a little bit recently :(

I want to refactor the python auto indenter. Like most auto indenters, it grew into a crazy set of rules pretty fast. Not my finest hour.

I think we need to break it out into a couple of stages. One to determine the mode we are in, and another stage to perform the indentation based on that understanding.

It might be worth while to sit down and work through what those steps would be. For example, what is the logical order that we need to follow for indenting? What takes precedence?
Comment 2 Christian Hergert 2015-01-20 04:31:00 UTC
Created attachment 294941 [details] [review]
python: fix indent after function call statement

This fixes indent after something like:

  "foo".format(bar, len(baz))
Comment 3 Christian Hergert 2015-01-20 04:33:35 UTC
Attachment 294941 [details] pushed as 2773c17 - python: fix indent after function call statement