Conversation
| return false; | ||
| } | ||
|
|
||
| if (hasHardLineBreak(baseLine) || hasHardLineBreak(currentLine)) { |
There was a problem hiding this comment.
nit: it's a little inconsistent that some regex-es are tested as "variable.test(...)" and some are wrapped into local functions.
justingrant
left a comment
There was a problem hiding this comment.
Sorry I was too late to review this before it was merged, but I think there are a few test cases that look wrong. I also provided a few additional test cases that may be helpful.
| @@ -222,4 +222,12 @@ | |||
| assert.strictEqual(result?.title, 'title'); | |||
| assert.strictEqual(result?.body, 'Wrapped paragraph across lines.\n\n- Item 1\n - Nested item\n More nested content\n- Item 2\n\nAnother wrapped paragraph here.'); | |||
There was a problem hiding this comment.
Same here: I think the nested lines should be merged.
| assert.strictEqual(result?.body, 'Wrapped paragraph across lines.\n\n- Item 1\n - Nested item\n More nested content\n- Item 2\n\nAnother wrapped paragraph here.'); | |
| assert.strictEqual(result?.body, 'Wrapped paragraph across lines.\n\n- Item 1\n - Nested item More nested content\n- Item 2\n\nAnother wrapped paragraph here.'); |
There was a problem hiding this comment.
I think since they have preceding whitespace they shouldn't be merged, right? The preceding whitespace indicates an intentional new line, where as no preceding whitespace should be unwrapped.
There was a problem hiding this comment.
Actually, I see github.com does unwrap these.
|
|
||
| const result = await titleAndBodyFrom(message); | ||
| assert.strictEqual(result?.title, 'title'); | ||
| assert.strictEqual(result?.body, 'This is wrapped text that should be joined.\n\n- List item with\n continuation\n- Another item'); |
There was a problem hiding this comment.
Something weird is happening with the display of this suggestion where the original code is shown as a blank line. But anyways the list continuation line should not have a line-break before it.
| assert.strictEqual(result?.body, 'This is wrapped text that should be joined.\n\n- List item with continuation\n- Another item'); |
| assert.strictEqual(result?.body, 'Wrapped paragraph across lines.\n\n- Item 1\n - Nested item\n More nested content\n- Item 2\n\nAnother wrapped paragraph here.'); | ||
| }); | ||
|
|
||
| it('handles nested lists', async function () { |
There was a problem hiding this comment.
@alexr00 Sorry, I wasn't quick enough to review this PR before merging, but I'd suggest adding a few more test cases, including some using numbered list items which are harder to implement than unordered lists because the numeric part can be variable-length. Also, the number of spaces is actually quite lenient in GitHub. Finally, code blocks and additional paragraphs are also supported in GH lists, so should probably have test cases for those.
I didn't review this PR code closely, but I did see a few 2's in the PR code, so wanted to make sure that you weren't assuming that the list indentation was always 2 spaces per level and/or that the list marker was always one character.
Here's some test cases, adapted from https://chatgpt.com/share/695c1f08-b928-8004-88c1-79417405b729. All the cases above should have their lines joined where there's a single \n. I apologize if some of these duplicate codepaths that were tested in other tests!
I suspect it'd be good to also make nested versions of these tests... I'll leave that as an exercise for copilot! :-)
-
Basic numeric list
continuation.
Third line -
Additional spaces are
OK for a continuation (unless it's 4 spaces which would be a code block).
Third line
- Additional spaces are
OK for a continuation (unless it's 4 spaces which would be a code block).
Third line
-
Multi-digit numbers should also
work for a continuation.
Third line -
Multi-paragraph lists are also supported.
Second paragraph in the same list item.
Third line
-
Multi-paragraph lists are also supported.
Second paragraph in the same list item.
Third line
-
Item with code:
code line code line
-
Item with code:
code line code line
- Fewer spaces are also OK
for a list continuation (as long as there's at least one space)
- Fewer spaces are also OK
for a list continuation (as long as there's at least one space)
- Fewer spaces are also OK
for a list continuation (as long as there's at least one space)
- Fewer spaces are also OK
for a list continuation (as long as there's at least one space)
There was a problem hiding this comment.
Thank you for the test cases!
See #8255 (comment)