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

Trim whitespace to right of cursor in some cases #73

Merged
merged 3 commits into from
Oct 27, 2020

Conversation

kbrose
Copy link
Owner

@kbrose kbrose commented Oct 27, 2020

Checklist

  • Relevant issues have been referenced
  • CHANGELOG.md has been updated (bullet points added to the Unreleased section)
  • Tests have been added, or are not relevant

Description

Whitespace to the right of the cursor will now be deleted when pressing Enter. This only happens if there is non-whitespace located somewhere both to the left and to the right of the cursor.

Examples, as usual, | represents the cursor.

def f(x,| y):        # The extra space IS deleted
  | print(x)         # The space to the right IS NOT deleted - no non-whitespace to the left
    print(y)|<space> # The space to the right IS NOT deleted - no non-whitespace to the right

In this way, both of the following situations end up with the right indentation:

def my_func(arg1,| arg2):


def my_func(arg1, |arg2):

# Both end up here:

def my_func(arg1,
            arg2):

# There may be an extra space after arg1 in the second case. If this is a problem
# for you, then use the files.trimTrailingWhitespace setting in VSCode.

Closes #62

@kbrose kbrose merged commit 747174c into master Oct 27, 2020
@kbrose kbrose deleted the intermediate-whitespace branch October 27, 2020 04:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Space after line break
1 participant