Skip to content

fix(editor): make list toolbar actions work in empty editor - #1629

Open
hgaol wants to merge 5 commits into
apache:devfrom
hgaol:1620
Open

hgaol wants to merge 5 commits into
apache:devfrom
hgaol:1620

Conversation

@hgaol

@hgaol hgaol commented Sep 20, 2026

Copy link
Copy Markdown
Member

Fixes #1620

Proposed Changes

  • Read the active line directly from CodeMirror state instead of calling the
    adapter-only getCursor() method.
  • Insert the appropriate Markdown marker (1. or - ) when a list action is
    used on a blank line.
  • Add regression tests covering ordered and unordered list toolbar actions
    through the CodeMirror adapter.
  • Move the comment border declaration before its nested rule to remove the Sass
    mixed-declaration warning.

Verification

  • cd ui && pnpm test
  • cd ui && pnpm build
  • ESLint and ASF header checks pass

Blank lines were skipped by the line replacement logic, causing ordered and unordered list toolbar actions to do nothing in an empty editor.
List commands were calling getCursor on the raw EditorView retained by the command adapter. Read the current line directly from CodeMirror state so toolbar actions reach the list insertion logic.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The added pnpm test script is likely not running the new deep-nested test file due to non-recursive glob expansion in typical package-script shells.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

Fixes the editor toolbar’s ordered/unordered list actions so they work when invoked in an empty (or blank-line) CodeMirror editor, and adds regression coverage plus a small Sass cleanup.

Changes:

  • Update list insertion commands to read the active line via CodeMirror selection state and insert a Markdown list marker on blank lines.
  • Add Node --test-based regression tests for ordered and unordered list toolbar commands through the CodeMirror adapter.
  • Reorder a Sass declaration in the comment component to avoid Sass mixed-declaration warnings.
File Description
ui/​src/​components/​Editor/​utils/​codemirror/​commands.ts Inserts list markers on blank lines and reads active line from CodeMirror selection state.
ui/​src/​components/​Editor/​utils/​codemirror/​commands.test.cjs Adds regression tests for list toolbar behavior via the CodeMirror adapter.
ui/​src/​components/​Comment/​index.scss Moves border-bottom before nested rules to avoid Sass warnings.
ui/​package.json Adds a pnpm test script for running the new Node tests.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread ui/package.json
Comment thread ui/src/components/Editor/utils/codemirror/commands.test.cjs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants