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

strip spaces after backslash-escaped newline #41245

Merged
merged 3 commits into from
Jun 29, 2021

Conversation

simeonschaub
Copy link
Member

@simeonschaub simeonschaub commented Jun 16, 2021

This was discussed on Slack with @StefanKarpinski and @BioTurboNick and
the general consensus was that stripping all spaces following a
backslash-escaped newline would make more sense than the current
behavior. Stripping the newline and spaces after a backslash now happens
before detenting for triple-quoted srings, so in cases like

"""
  a\
b
  c"""

the b doesn't affect detenting and the spaces before a and c are
removed.

This was discussed on Slack with @StefanKarpinski and @BioTurboNick and
the general consensus was that stripping all spaces following a
backslash-escaped newline would make more sense than the current
behavior. One subtle distinction here is whether this stripping should
happen before or after triple-quoted strings. Right now it happens after
detenting so

```julia
"""
  a\
b"""
```

produces `"  ab"`, whereas if it would be the other way around, escaped
newlines would not affect detenting so the spaces preceding the `a`
would be removed.
@simeonschaub simeonschaub added needs decision A decision on this change is needed parser Language parsing and surface syntax strings "Strings!" triage This should be discussed on a triage call backport 1.7 labels Jun 16, 2021
@simeonschaub simeonschaub added this to the 1.7 milestone Jun 16, 2021
@BioTurboNick
Copy link
Contributor

BioTurboNick commented Jun 16, 2021

Seems like it would make the most sense to have escaped newlines not participate in the dedentation logic, so that:

"""
        This is my first very long sentence \
which finishes here.
    This is my second sentence.
"""

is equivalent to

"""
        This is my first very long sentence which finishes here.
    This is my second sentence.
"""

@StefanKarpinski
Copy link
Member

Agree: it seems better that line continuation and dedent determination not interact, i.e. the line joining should happen before the dedent is determined.

@KristofferC KristofferC mentioned this pull request Jun 17, 2021
20 tasks
@JeffBezanson
Copy link
Member

👍 from triage, also to doing the line joining before dedenting.

@JeffBezanson JeffBezanson removed the triage This should be discussed on a triage call label Jun 17, 2021
@simeonschaub simeonschaub removed the needs decision A decision on this change is needed label Jun 17, 2021
@simeonschaub simeonschaub force-pushed the sds/backslash_rm_all_spaces branch from 8e6963a to 5b10327 Compare June 17, 2021 21:53
@simeonschaub simeonschaub changed the title RFC: strip spaces after backslash-escaped newline strip spaces after backslash-escaped newline Jun 18, 2021
@simeonschaub simeonschaub force-pushed the sds/backslash_rm_all_spaces branch from cbd87ec to cb2f15f Compare June 29, 2021 13:19
@simeonschaub simeonschaub merged commit be08627 into master Jun 29, 2021
@simeonschaub simeonschaub deleted the sds/backslash_rm_all_spaces branch June 29, 2021 15:31
KristofferC pushed a commit that referenced this pull request Jun 30, 2021
This was discussed on Slack with @StefanKarpinski and @BioTurboNick and
the general consensus was that stripping all spaces following a
backslash-escaped newline would make more sense than the current
behavior. Stripping the newline and spaces after a backslash now happens
before detenting for triple-quoted srings, so in cases like

```julia
"""
  a\
b
  c"""
```

the `b` doesn't affect detenting and the spaces before `a` and `c` are
removed.

(cherry picked from commit be08627)
johanmon pushed a commit to johanmon/julia that referenced this pull request Jul 5, 2021
This was discussed on Slack with @StefanKarpinski and @BioTurboNick and
the general consensus was that stripping all spaces following a
backslash-escaped newline would make more sense than the current
behavior. Stripping the newline and spaces after a backslash now happens
before detenting for triple-quoted srings, so in cases like

```julia
"""
  a\
b
  c"""
```

the `b` doesn't affect detenting and the spaces before `a` and `c` are
removed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parser Language parsing and surface syntax strings "Strings!"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants