Skip to content

fix(bug): list continuation line handling and refactor shared utilities#110

Merged
YousefHadder merged 2 commits intomainfrom
fix-list-continuation
Nov 5, 2025
Merged

fix(bug): list continuation line handling and refactor shared utilities#110
YousefHadder merged 2 commits intomainfrom
fix-list-continuation

Conversation

@YousefHadder
Copy link
Copy Markdown
Owner

Summary

This PR fixes a bug where pressing Alt-Enter on an ordered list item caused subsequent items to be incorrectly renumbered, and includes code quality improvements.

Changes

Bug Fix

  • Fixed renumbering issue when continuation lines are added with Alt-Enter
  • Added is_continuation_line detection logic to prevent treating continuation lines as list-breaking lines
  • Modified is_list_breaking_line to check for continuation lines before treating blank/non-list lines as breaks

Refactoring

  • Created lua/markdown-plus/list/shared.lua module to eliminate ~180 lines of duplicate code
  • Centralized common utilities: is_orderable_type, extract_list_content, get_content_start_col, get_marker_for_index, find_parent_list_item, is_continuation_line
  • Updated handlers.lua and renumber.lua to use shared utilities

Function Rename

  • Renamed handle_shift_enter to continue_list_content for clarity
  • Updated across all files: handlers.lua, init.lua, list_spec.lua, markdown-plus.txt

Testing

  • Added 4 comprehensive tests for continuation line scenarios
  • All 94 tests passing
  • All quality checks passing (lint, format, tests)

Files Changed

  • lua/markdown-plus/list/shared.lua (new)
  • lua/markdown-plus/list/handlers.lua
  • lua/markdown-plus/list/renumber.lua
  • lua/markdown-plus/list/init.lua
  • spec/markdown-plus/list_spec.lua
  • doc/markdown-plus.txt

Copilot AI review requested due to automatic review settings November 5, 2025 16:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug where continuation lines (created with Alt-Enter) were incorrectly treated as list breaks, causing ordered list items to be renumbered unexpectedly. It also consolidates ~180 lines of duplicate code into a shared utilities module.

Key changes:

  • Introduced continuation line detection to prevent incorrect list break detection
  • Created shared.lua module to centralize common list utilities
  • Renamed handle_shift_enter to continue_list_content for better clarity

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
lua/markdown-plus/list/shared.lua New module containing shared utilities for list handling (continuation line detection, content extraction, marker generation)
lua/markdown-plus/list/renumber.lua Updated to use shared utilities and check for continuation lines before treating lines as list breaks
lua/markdown-plus/list/handlers.lua Refactored to use shared utilities; renamed handle_shift_enter to continue_list_content
lua/markdown-plus/list/init.lua Updated function name reference from handle_shift_enter to continue_list_content
spec/markdown-plus/list_spec.lua Added 4 tests for continuation line scenarios; updated function name references
doc/markdown-plus.txt Updated documentation for renamed function

@YousefHadder YousefHadder changed the title Fix list continuation line handling and refactor shared utilities fix(bug): list continuation line handling and refactor shared utilities Nov 5, 2025
@YousefHadder YousefHadder requested a review from Copilot November 5, 2025 16:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

@YousefHadder YousefHadder merged commit 51116c8 into main Nov 5, 2025
14 checks passed
@YousefHadder YousefHadder deleted the fix-list-continuation branch November 5, 2025 16:36
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