Skip to content
This repository has been archived by the owner on Sep 12, 2018. It is now read-only.

Fix up the reflow behavior of MD lists, a bunch of comment styles, and ascii email inclusions #45

Merged
merged 4 commits into from
Dec 14, 2017

Conversation

satchm0h
Copy link

@satchm0h satchm0h commented Mar 8, 2016

Changes to address issues #4, #36, #39, #43

  • Fixed reflow of lists with '-' line prefix
    • Added test
  • Fixed reflow of '/*' block comments
    • Added test
  • Added support for reflow of '%' single line comments
    • Added test
  • Added support for reflow of ';;' single line comments
    • Added test
  • Added support for reflow of '>' ascii email inclusions
    • Added test
  • Added test for '#' single line comments
  • Added test for '//' single line comments

- Fixed reflow of lists with '-' line prefix
  - Added test
- Fixed reflow of '/*' block comments
  - Added test
- Added support for reflow of '%' single line comments
  - Added test
- Added support for reflow of ';;' single line comments
  - Added test
- Added support for reflow of '>' ascii email inclusions
  - Added test
- Added test for '#' single line comments
- Added test for '//' single line comments
@satchm0h
Copy link
Author

Any thoughts on getting this reviewed?

@50Wliu
Copy link
Contributor

50Wliu commented Mar 28, 2016

Any thoughts on getting this reviewed?

Unfortunately there's more open PRs than the Atom team can review, so there's currently a long backup. It might take some time until someone can give this a thorough review.

@@ -68,11 +68,22 @@ module.exports =
currentLine = []
currentLineLength = linePrefixTabExpanded.length

notFirstLine = false
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be easier to understand if this was switched: firstLine = true

@satchm0h
Copy link
Author

satchm0h commented May 5, 2016

Ping?

@mturilli
Copy link

Thank you satchm0h. This patch is relevant to my activity, I am happy to help however I can with the review process.

@mdlinville
Copy link

I would love to see this get in. I looked over the changes and they look great. If you can tell me how to test this locally, I'd love to do it.

@50Wliu
Copy link
Contributor

50Wliu commented Nov 16, 2016

@mstanleyjones apm dev autoflow [directory]. Then open Atom using atom --dev.

@alflanagan
Copy link

alflanagan commented Sep 19, 2017

It's ... stunning ... that this simple fix has been under needs-review for a year and a half. How does one get approved to do reviews? Meanwhile I'm trying package magic-reflow.
UPDATE: apparently I can review, so I'm gearing up to do that. magic-reflow unfortunately didn't solve the use cases I have.

@satchm0h
Copy link
Author

satchm0h commented Sep 27, 2017 via email

Copy link
Contributor

@maxbrunsfeld maxbrunsfeld left a comment

Choose a reason for hiding this comment

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

Sorry that it took forever for us to get to this. I left a couple of comments.

@@ -311,3 +311,145 @@ describe "Autoflow package", ->
'''

expect(autoflow.reflow(text, wrapColumn: 2)).toEqual res

it 'properly reflows // comments ', ->
# Because there're known problems with this character in major regex engines
Copy link
Contributor

@maxbrunsfeld maxbrunsfeld Sep 28, 2017

Choose a reason for hiding this comment

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

Does this comment apply to this example? It seems like it was copied over from a different test, but I don't think regex engines have problems with / characters.

linePrefix = linePrefix.replace(/^(\s*)\/\*/, '$1 ')
# Handle - list items
else if linePrefix.search(/^\s*-/) isnt -1
linePrefix = linePrefix.replace(/^(\s*)[\/#*-]/, '$1 ')
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. It looks like this processing of linePrefix could be moved outside of the loop; it doesn't depend on the loop variable segment. It looks like you've done it here because you need a different line prefix for the first line than for the remainder of the lines. Maybe before the loop you could define a second variable called wrappedLinePrefix.

  2. I don't think it's necessary to first check that linePrefix matches a regex before calling replace on it with that regex. It's ok to call replace with a non-matching regex; it will just return the string unchanged.

Maybe something like this?

wrappedLinePrefix = linePrefix
  .replace(/^(\s*)\/\*/, '$1  ')
  .replace(/^(\s*)-/, '$1 ')

firstLine = true
for segment in @segmentText(blockLines.join(' '))
  if @wrapSegment(segment, currentLineLength, wrapColumn)

    if firstLine
      # use `linePrefix`
    else
      # use `wrappedLinePrefix`

@50Wliu
Copy link
Contributor

50Wliu commented Nov 15, 2017

@satchm0h are you interested in addressing @maxbrunsfeld's comments?

@maxbrunsfeld maxbrunsfeld merged commit ab79933 into atom:master Dec 14, 2017
@maxbrunsfeld
Copy link
Contributor

Thanks @satchm0h! Nice work!

@mdlinville
Copy link

OMG! 🎉

@maxbrunsfeld
Copy link
Contributor

This will go out in Atom 1.25.

@satchm0h
Copy link
Author

Wonders never cease ;)

@50Wliu
Copy link
Contributor

50Wliu commented Dec 20, 2017

Hmm, I just identified some minor issues with this PR, specifically regarding the addition of the ;; comment character. Since you added it inside a character class, it's actually just matching ;. I'll see if I can get that fixed up in a follow-up PR.

@50Wliu 50Wliu mentioned this pull request Dec 21, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants