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

Handle newline at start or end of section #53

Merged
merged 1 commit into from
Aug 11, 2015

Conversation

bantic
Copy link
Collaborator

@bantic bantic commented Aug 10, 2015

Handle newline at start of section

  • simplify section#splitMarker
  • tests for hitting enter in middle and end of section
  • add test for hitting enter in first section
  • fix bug with PostNodeBuilder not assigning a builder to the blank marker

fixes #39

@bantic bantic force-pushed the newline-at-section-start branch from 1c61002 to db8690f Compare August 10, 2015 17:48
} else {
// start of section, remove the existing marker and add a blank one
section.markers.remove(marker);
section.markers.append(this.builder.createBlankMarker());
Copy link
Contributor

Choose a reason for hiding this comment

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

Not needed, but alternatively:

section.markers.splice(marker, 1, [this.builder.createBlankMarker()]);

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I'm sorry, I misread this. You're removing a marker from some arbitrary place and only appending the blank marker, all the time.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused- shouldn't the blank marker be in a new section?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, agreed, this is fairly confusing. I'm reworking this to be a bit more declarative.

@bantic
Copy link
Collaborator Author

bantic commented Aug 10, 2015

hold off on merging for the moment. I'm reworking Marker.split and the way Section uses it, which will hopefully make this a simpler operation to code (and the code simpler to read).

@mixonic mixonic mentioned this pull request Aug 10, 2015
30 tasks
  * simplify section#splitMarker
  * tests for hitting enter in middle and end of section
  * add test for hitting enter in first section
  * fix bug with PostNodeBuilder not assigning a builder to the blank marker

fixes #39
@bantic bantic force-pushed the newline-at-section-start branch from db8690f to 3f113b3 Compare August 11, 2015 18:24
@bantic
Copy link
Collaborator Author

bantic commented Aug 11, 2015

@mixonic this is ready now if you want to look it over

*/
coalesceMarkers() {
forEach(
filter(this.markers, m => m.empty()),
Copy link
Contributor

Choose a reason for hiding this comment

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

m.empty should probably be m.isEmpty

Also doing a filter only to pass it to another iterator seems wasteful- this could be done in a single pass with an if

Copy link
Contributor

Choose a reason for hiding this comment

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

changed the loop on master, we can ponder empty

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mixonic removing markers while iterating them causes the iteration to skip (item.next is something different before/after the callback). I have a PR coming to fix iteration of the linkedlist

mixonic added a commit that referenced this pull request Aug 11, 2015
Handle newline at start or end of section
@mixonic mixonic merged commit 250a976 into master Aug 11, 2015
@mixonic mixonic deleted the newline-at-section-start branch August 11, 2015 18:37
@bantic bantic mentioned this pull request Aug 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pressing enter at the start of a line/section has unexpected results
2 participants