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

cmark files and multiline fragments #74

Merged
merged 30 commits into from
Jul 23, 2020
Merged

cmark files and multiline fragments #74

merged 30 commits into from
Jul 23, 2020

Conversation

drahnr
Copy link
Owner

@drahnr drahnr commented Jul 16, 2020

What does this PR accomplish?

Does all handling of multiline literals, except for displaying, which must be handled in a separate PR.

Closes #37 which requires proper handling of chunks with multiline fragments

Changes proposed by this PR:

  • Calculate a full span for common mark files and the associated mapped range.
  • Extract spans from multiline fragments.
  • feather_up! for testability

@drahnr drahnr added enhancement 🦚 New feature or request heavy-duty 🚜 Big features not easy to implement labels Jul 16, 2020
@drahnr drahnr self-assigned this Jul 16, 2020
@drahnr
Copy link
Owner Author

drahnr commented Jul 16, 2020

@zhiburt e535f38 is the relevant part for #37 - I was not aware things would explode afterwards at multiple code segments, I am sorry having you sent there.

@drahnr drahnr requested a review from KuabeM July 16, 2020 11:09
@@ -403,11 +403,14 @@ impl UserPicked {
}

let event = match crossterm::event::read()
.map(move |event| {
drop(guard);
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@@ -435,7 +437,6 @@ impl UserPicked {
}
}

drop(guard);
Copy link
Collaborator

Choose a reason for hiding this comment

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

That drop() is unnecessary because drop for ScopedRaw in line 424 is called when it goes out of scope and now it's ensured that all earlier guards are properly dropped right? Just for my understanding :)

Copy link
Owner Author

Choose a reason for hiding this comment

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

I am not sure if the current approach is sane, there seem to be a few artificats in the cli, cursor showing and lines being off by one, just because we leave raw mode, so this might have to be reverted eventually.

.skip_while(|(sub, _span)| sub.end <= start)
.take_while(|(sub, _span)| end <= sub.end)
.skip_while(|(fragment_range, _span)| fragment_range.end <= start)
.take_while(|(fragment_range, _span)| end <= fragment_range.end)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like the new variable names 👍

Copy link
Collaborator

Choose a reason for hiding this comment

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

what does fragment_range means here? if I may ask

Copy link
Owner Author

@drahnr drahnr Jul 17, 2020

Choose a reason for hiding this comment

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

src/documentation/chunk.rs Outdated Show resolved Hide resolved
src/documentation/chunk.rs Outdated Show resolved Hide resolved
src/documentation/chunk.rs Show resolved Hide resolved
src/documentation/mod.rs Outdated Show resolved Hide resolved
@drahnr drahnr force-pushed the bernhard-cmark-files branch from 9d0ee93 to 01aefc2 Compare July 17, 2020 13:38
@drahnr drahnr force-pushed the bernhard-cmark-files branch from 01aefc2 to b8012a3 Compare July 17, 2020 13:48
@drahnr drahnr requested a review from KuabeM July 17, 2020 15:31
src/documentation/chunk.rs Show resolved Hide resolved
src/documentation/chunk.rs Outdated Show resolved Hide resolved
return None;
}
.filter_map(|(fragment_range, fragment_span)| {
// trim range so we only capture the relevant part
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is considered an irrelevant part?

Copy link
Owner Author

Choose a reason for hiding this comment

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

It's not about irrelevant, it's a coverage problem of the given input range on the set of fragmented ranges. Note the fragmentation is caused by clustering of multiple literals. A fragment is a mere description of a range/span couple concept of a chunk.

src/span.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@laysauchoa laysauchoa left a comment

Choose a reason for hiding this comment

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

Short question: does this PR helps to fix chunk for single lines? or helps me here: #65?

@drahnr
Copy link
Owner Author

drahnr commented Jul 17, 2020

Short question: does this PR helps to fix chunk for single lines? or helps me here: #65?

No, this prepares all systems except for suggestion or chunk display impl for multiline fragments. So this does not interfere with or fix #65

Co-authored-by: Laysa Uchoa <[email protected]>
src/documentation/chunk.rs Outdated Show resolved Hide resolved
src/documentation/chunk.rs Outdated Show resolved Hide resolved
@drahnr
Copy link
Owner Author

drahnr commented Jul 17, 2020

Short question: does this PR helps to fix chunk for single lines? or helps me here: #65?

No, this prepares all systems except for suggestion or chunk display impl for multiline fragments. So this does not interfere with or fix #65

@laysauchoa the above is intentional to avoid you having to deal with merge conflicts, the display is going to be a separate PR once #74 and #65 are in master.

@drahnr drahnr force-pushed the bernhard-cmark-files branch from 82494df to 342eb39 Compare July 23, 2020 13:59
@drahnr drahnr requested a review from KuabeM July 23, 2020 14:13
@drahnr drahnr merged commit 85d5b34 into master Jul 23, 2020
@drahnr drahnr deleted the bernhard-cmark-files branch July 23, 2020 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🦚 New feature or request heavy-duty 🚜 Big features not easy to implement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

handle markdown files
3 participants