-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Desktop: Fixes #4877: Incorrect list renumbering #4914
Conversation
The pull request should indeed be based on #4832 once it has been merged. That other pull request also adds test units for this part of the code, so you'll be able to add yours too for the manual tests you mentioned above. |
@laurent22 sounds good, I will rebase and wait for that PR to be merged. It seems it is close. Thank you! |
For information the other pull request has been merged now. |
@laurent22 thanks! I updated the PR and ran into one more test case where the behavior is unclear to me what is desired. I also think fixing it requires touching more code than what is covered by The following
becomes
or
Depending on if it is selected with
Let me know how I should handle this case, and if it should be this PR or another. |
Your tests aren't passing at the moment: https://travis-ci.org/github/laurent22/joplin/jobs/769582849#L912 |
@laurent22 sorry about that! Haven't quite worked out the workflow yet, forgot to recompile typescript before running the tests. Updated the test cases. I also removed the |
packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/utils/useCursorUtils.test.ts
Outdated
Show resolved
Hide resolved
That was just for checking deep equality; using |
@lkiThakur ah thanks for the clarification! I thought it might be something like that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update, I think it's nearly there. Also for some reason I see that there was no tests added to handle lists with gaps in it. Could you add one please, just to make sure we're preserving this behaviour?
So this:
one
two
three
should be come this:
1. one
2. two
3.
4. three
expect(modifyListLines([...listWithOnes], 2, '1. ')).toStrictEqual(listWithNoPrefixes); | ||
}); | ||
|
||
test('should remove "n. " from each line that has it, and add it to the lines which do not', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is the best behaviour because if the user selects a block, they want either all the numbers to be gone, or add numbers to each lines, but I don't think they want a mix of both. Perhaps you could check the first item - if it's a number, remove all numbers, and if there's no number, add a number to each line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure that makes sense. Should it be just the first line or any line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First line I guess?
I wanted to minimise the efforts if switching to other discussed behaviours in future, however if we are preserving this behaviour then someone could add these lines to the useCursorUtils.test.ts file(in the callback of describe) const numberedListWithEmptyLines=[
'1. item1',
'2. item2',
'3. ' ,
'4. item3',
];
const noPrefixListWithEmptyLines = [
'item1',
'item2',
'' ,
'item3',
];
test('should add numbers to each line including empty one', () => {
expect(modifyListLines(noPrefixListWithEmptyLines,1,'1. ')).toStrictEqual(numberedListWithEmptyLines)
}) |
@austindoupnik, are you still ok with completing this pull request? There are a few tweaks to make, but I think it's nearly there. |
@laurent22 yep! I was out for a few days, but will work on the changes now. thanks! |
@laurent22 FYI |
Ok looks good I think, so let's merge |
@laurent22 thank you! |
These changes are related to/have a minor conflict with PR #4832. Please let me know how I can help get that PR merged, then I can rebase and add some additional test cases. I would also be happy to port the testing changes over to my branch and add test cases.
Here is what I found through manual testing (the expected behavior is the behavior after this patch):
Note: Case C and Case D were working and continue to work, just wanted to test all the code paths.
Case A
Steps to Reproduce
Actual
Expected
Case B
Steps to Reproduce
Actual
Expected
Case C
Steps to Reproduce
Actual
Expected
Case D
Steps to Reproduce
Actual
Expected
Case E
Steps to Reproduce
Actual
Expected