Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,18 @@ class RichSpanManager(
(end.line == deletionPoint.line && end.char <= deletionPoint.char) -> {
updatedSpans.add(span)
}
// Span is entirely below the joined line — the deleted newline pulls
// every following line up by one, so decrement its line index.
start.line > nextLineStart.line -> {
updatedSpans.add(
span.copy(
range = TextEditorRange(
start = CharLineOffset(start.line - 1, start.char),
end = CharLineOffset(end.line - 1, end.char)
)
)
)
}
// Span is entirely on the second line
start.line == nextLineStart.line -> {
val newStart = CharLineOffset(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,21 @@ class OrderedListSerializationTest {
assertEquals("1. onetwo", extension.exportAsMarkdown())
}

@Test
fun `deleting a middle ordered-list item keeps following items in the list`() = runTest {
val extension = createMarkdownExtension()
extension.importMarkdown("1. one\n2. two\n3. three\n4. four")

val state = extension.editorState
// Merge item 2 into item 1 via a single-newline delete (backspace at col 0
// of a same-block line). Items 3 and 4 must keep their spans and renumber.
state.cursor.updatePosition(CharLineOffset(1, 0))
state.backspaceAtCursor()

assertEquals(listOf(0, 1, 2), extension.orderedLines())
assertEquals("1. onetwo\n2. three\n3. four", extension.exportAsMarkdown())
}

@Test
fun `enter on empty ordered-list item exits the list`() = runTest {
val extension = createMarkdownExtension()
Expand Down
Loading