fix: consecutive numbering fails after indented sub-bullets (#7447)

* fix: consecutive numbering fails after indented sub-bullets

The applyNumberList() function in renumberList() checked
listType[0] === 'indent' but after regex exec, listType[0] is the
full match (e.g., "indent1"), never just "indent". Changed to
listType[1] which is the capture group containing just the type name.

This caused indent-type lines to not be recognized during renumbering,
breaking the numbering sequence when numbered lists followed indented
content.

Fixes #5718

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* test: assert sub-bullet indent and remove redundant waitForTimeout

- Assert .list-bullet2 exists after Tab to verify indent precondition
- Remove waitForTimeout(500) since toHaveAttribute already waits 5s

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
John McLear 2026-04-04 09:19:08 +01:00 committed by GitHub
parent f186ea9d2c
commit 928eef8978
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 45 additions and 1 deletions

View File

@ -2314,7 +2314,7 @@ function Ace2Inner(editorInfo, cssManagers) {
listType = /([a-z]+)([0-9]+)/.exec(listType);
curLevel = Number(listType[2]);
const curType = listType[1];
if (isNaN(curLevel) || listType[0] === 'indent') {
if (isNaN(curLevel) || listType[1] === 'indent') {
return line;
} else if (curLevel === level) {
// Reset position when switching between list types at the same level

View File

@ -92,6 +92,50 @@ test.describe('ordered_list.js', function () {
await expect(fifthLine.locator('ol')).toHaveAttribute('start', '3', {timeout: 5000});
});
// Regression test for https://github.com/ether/etherpad-lite/issues/5718
test('issue #5718 consecutive numbering works after indented sub-bullets', async function ({page}) {
const padBody = await getPadBody(page);
await clearPadContent(page);
// Create a bullet point
const $insertUnorderedButton = page.locator('.buttonicon-insertunorderedlist');
await $insertUnorderedButton.click({force: true});
await writeToPad(page, 'Bullet item');
await page.keyboard.press('Enter');
// Indent to create a sub-bullet
await page.keyboard.press('Tab');
await writeToPad(page, 'Sub-bullet');
// Verify the sub-bullet is actually indented (level 2)
const subBulletLine = padBody.locator('div').nth(1);
await expect(subBulletLine.locator('.list-bullet2')).toHaveCount(1, {timeout: 5000});
await page.keyboard.press('Enter');
// De-indent back to level 1
await page.keyboard.press('Shift+Tab');
// Switch to numbered list
const $insertOrderedButton = page.locator('.buttonicon-insertorderedlist');
await $insertOrderedButton.click({force: true});
await writeToPad(page, 'Number 1');
await page.keyboard.press('Enter');
await writeToPad(page, 'Number 2');
await page.keyboard.press('Enter');
await writeToPad(page, 'Number 3');
// Lines 3, 4, 5 should be numbered 1, 2, 3
const line3 = padBody.locator('div').nth(2);
await expect(line3.locator('ol')).toHaveAttribute('start', '1', {timeout: 5000});
const line4 = padBody.locator('div').nth(3);
await expect(line4.locator('ol')).toHaveAttribute('start', '2', {timeout: 5000});
const line5 = padBody.locator('div').nth(4);
await expect(line5.locator('ol')).toHaveAttribute('start', '3', {timeout: 5000});
});
test.describe('Pressing Tab in an OL increases and decreases indentation', function () {
test('indent and de-indent list item with keypress', async function ({page}) {