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

[JEWEL-600] Use chars indexes for markdown edits #2922

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

obask
Copy link
Collaborator

@obask obask commented Jan 21, 2025

Our previouis version was marking a previouis
and the following blocks as modified, while it's
not needed in most cases.

We can use use 0.24.0 inputIndex parameter to
simply keep an index from char to block and avoid
splitting lines and doing complicated search for
a modified substring.

@obask
Copy link
Collaborator Author

obask commented Jan 21, 2025

TODO: address Jacob's suggestions:
Perhaps I'm just unfamiliar with this repo but I don't think this function is very readable (but approving as the first iteration wasn't either imo).

Please consider renaming variables or extracting some functionality into smaller functions that explain themselves in the title, and/or adding some more larger comments.

e.g. all the stuff about prefix, suffix, and positions doesn't really make sense in the context of processing a string which represents markdown imo. Perhaps textMatchingBeforeEdits and and textMatchingAfterEdits, would be more appropriate. Additionally, firstBlock could be firstMarkdownBlockThatNeedsProcessed or firstChangedMarkdownBlock

A comment explaining what the function is doing at the high level would help a lot too. e.g. "Process markdown quickly by comparing it to the previously processed markdown and discarding text that matched before the edits and after the edits by doing string comparisons on the text. After processing update our state again with our newly processed markdown blocks." (or something) or perhaps just a comment showing an example would help e.g. "abcdefg" vs "abcefg".

@rock3r rock3r requested review from AlexVanGogen and rock3r and removed request for AlexVanGogen January 21, 2025 17:11
@rock3r
Copy link
Collaborator

rock3r commented Jan 21, 2025

@obask please always preface PR titles with [JEWEL] or [JEWEL-xxx] (where xxx is the issue ID) as per the guidelines I shared with you ~a month ago

@obask obask changed the title Use chars instead of lines indexes [JEWEL-600] Use chars indexes for markdown edits Jan 31, 2025
@obask obask force-pushed the use-char-indexes-instead-of-lines branch 3 times, most recently from 23ad03d to 56452a3 Compare February 5, 2025 17:26
@AlexVanGogen
Copy link
Contributor

@obask Is it still a draft? Are there any other substantial changes planned?

@rock3r
Copy link
Collaborator

rock3r commented Feb 7, 2025

Yesterday he said he'd rebase to solve the CI issues and mark as ready to review. @obask can you please do it?

@obask obask force-pushed the use-char-indexes-instead-of-lines branch 2 times, most recently from 151ba05 to 738b568 Compare February 10, 2025 18:42
@rock3r rock3r added the jewel label Feb 11, 2025
@rock3r
Copy link
Collaborator

rock3r commented Feb 11, 2025

@obask is this ready now? At the net of the CI fixes that are coming in #2941, can you address the outstanding comments?

@obask obask force-pushed the use-char-indexes-instead-of-lines branch from 738b568 to 4794382 Compare February 12, 2025 12:08
@obask obask marked this pull request as ready for review February 12, 2025 12:11
@rock3r
Copy link
Collaborator

rock3r commented Feb 12, 2025

@obask static analysis is failing, can you take a look?

@obask obask force-pushed the use-char-indexes-instead-of-lines branch from 4794382 to 2b8a55f Compare February 13, 2025 11:10
@obask
Copy link
Collaborator Author

obask commented Feb 13, 2025

@obask static analysis is failing, can you take a look?

Format project doesn't rearrange (star) imports, so I did it in an IDE. It should work now.

@obask obask requested a review from rock3r February 13, 2025 11:13
@rock3r
Copy link
Collaborator

rock3r commented Feb 13, 2025

There is still some static analysis issue (and yes, star imports are only really addressed by the IDE, because ktfmt doesn't have access to the classpath to resolve these imports)

Our previouis version was marking a previouis
and the following blocks as modified, while it's
not needed in most cases.

We can use use 0.24.0 inputIndex parameter to
simply keep an index from char to block and avoid
splitting lines and doing complicated search for
a modified substring.
@obask obask force-pushed the use-char-indexes-instead-of-lines branch from 2b8a55f to eee09a3 Compare February 13, 2025 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants