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

Spike on auto indentation #5821

Closed
luabud opened this issue May 28, 2019 · 5 comments
Closed

Spike on auto indentation #5821

luabud opened this issue May 28, 2019 · 5 comments
Assignees
Labels
area-formatting feature-request Request for new features or functionality

Comments

@luabud
Copy link
Member

luabud commented May 28, 2019

#481

@ghost ghost added the triage-needed Needs assignment to the proper sub-team label May 28, 2019
@luabud luabud added the needs proposal Need to make some design decisions label May 28, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label May 28, 2019
@luabud luabud added area-formatting feature-request Request for new features or functionality labels May 28, 2019
@DonJayamanne
Copy link

  • Look into using regex based on python grammar

@DonJayamanne DonJayamanne added this to the 2019 - May Sprint 11 milestone May 29, 2019
@jkyeung
Copy link

jkyeung commented Jun 7, 2019

Um, what is the purpose of this issue? Is it to basically bring issue #481 back to the forefront? Is the term "spike" here the same as (or perhaps a more forceful version of) what I've often seen as "bump" on various forums?

I certainly would not mind if this was moved to the front burner.

In particular, the "fix" for backslash line continuation is broken. Issues #4241 and #4563 deserve more attention.

I think it is a fairly simple matter, actually. The on-Enter rule that was added to address #3284 was this (in extension.ts):

{
    beforeText: /^(?!\s+\\)[^#\n]+\\\s*/,
    action: { indentAction: IndentAction.Indent }
}

It has the fatal flaw that the regex is not tied to the end of the line. I think that whoever put this in (apparently proposed by @jakebailey) probably meant the regex to be

/^(?!\s+\\)[^#\n]+\\\s*$/

Technically, that is still wrong, because the Python interpreter doesn't allow whitespace after the line-continuation backslash. It would be more correct as

/^(?!\s+\\)[^#\n]+\\$/

Since this is such a simple change and would save so many people the countless small headaches of unintended autoindentation after strings that contain backslash-escapes, I implore the powers that be to please give this some attention.

@brettcannon
Copy link
Member

@jkyeung Spikes are basically us putting in some research into how best to try and solve the problem.

@ericsnowcurrently
Copy link
Member

@jkyeung, I've left a comment on #3284 referring to your comment here. :)

@ericsnowcurrently
Copy link
Member

I took at look at the existing code. Without upstream vscode changes, there isn't a lot we can do there.

Here's one rule we could add that might help a little with the indent of closing brackets:

{
    afterText: /^\s*[)}\]]/,
    action: { indentAction: IndentAction.Outdent }
}

@ghost ghost removed the needs proposal Need to make some design decisions label Jun 11, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-formatting feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

5 participants