Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

Preserve nested list content when leaving an empty item (#35236)

OrcaWin523d8b14cd49
diff --git a/src/renderer/src/components/editor/rich-markdown-list-continuation.test.ts b/src/renderer/src/components/editor/rich-markdown-list-continuation.test.ts
index d7f8d5b5330..97ea94656dc 100644
--- a/src/renderer/src/components/editor/rich-markdown-list-continuation.test.ts
+++ b/src/renderer/src/components/editor/rich-markdown-list-continuation.test.ts
@@ -267,6 +267,45 @@ describe('rich markdown list continuation', () => {
}
})
+ it.each(['preceding paragraph', 'following paragraph', 'following list'] as const)(
+ 'preserves a %s when the nested item also contains an empty paragraph',
+ (placement) => {
+ const blank = { type: 'paragraph' }
+ const kept = { type: 'paragraph', content: [{ type: 'text', text: 'Keep' }] }
+ const content =
+ placement === 'following list'
+ ? [blank, { type: 'bulletList', content: [{ type: 'listItem', content: [kept] }] }]
+ : placement === 'preceding paragraph'
+ ? [kept, blank]
+ : [blank, kept]
+ const editor = createEditor({
+ type: 'doc',
+ content: [
+ {
+ type: 'orderedList',
+ content: [
+ {
+ type: 'listItem',
+ content: [
+ { type: 'paragraph', content: [{ type: 'text', text: 'Outer' }] },
+ { type: 'orderedList', content: [{ type: 'listItem', content }] }
+ ]
+ }
+ ]
+ }
+ ]
+ })
+ try {
+ editor.commands.setTextSelection(firstEmptyParagraphPosition(editor))
+ const before = editor.getJSON()
+ expect(convertEmptyNestedOrderedItemToContinuation(editor)).toBe(false)
+ expect(editor.getJSON()).toEqual(before)
+ } finally {
+ editor.destroy()
+ }
+ }
+ )
+
it('leaves non-empty nested ordered items to the default Backspace behavior', () => {
const editor = createEditor({
type: 'doc',
diff --git a/src/renderer/src/components/editor/rich-markdown-list-continuation.ts b/src/renderer/src/components/editor/rich-markdown-list-continuation.ts
index e47be2824f2..e8dd00de8be 100644
--- a/src/renderer/src/components/editor/rich-markdown-list-continuation.ts
+++ b/src/renderer/src/components/editor/rich-markdown-list-continuation.ts
@@ -185,7 +185,7 @@ export function convertEmptyNestedOrderedItemToContinuation(editor: Editor): boo
return false
}
- if (list.childCount !== 1) {
+ if (list.childCount !== 1 || $from.node(context.listItemDepth).childCount !== 1) {
return false
}