fix(bug): custom keymaps and list enter splitting bugs#108
fix(bug): custom keymaps and list enter splitting bugs#108YousefHadder merged 4 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes the keymap setup logic to always create <Plug> mappings regardless of keymaps.enabled configuration, and refines list handling behavior for cursor positioning and continuation lines. It also updates test expectations to reflect the actual Neovim API cursor clamping behavior.
- Modified keymap helper to create
<Plug>mappings unconditionally while only conditionally creating default keybindings - Refined list enter handler to differentiate between list item lines and continuation lines for split behavior
- Updated tests to match actual API cursor clamping behavior
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| lua/markdown-plus/keymap_helper.lua | Removes early return that prevented <Plug> mapping creation; adds condition check for default keymaps |
| lua/markdown-plus/list/handlers.lua | Adds continuation line tracking and distinct split logic for list items vs continuation lines |
| spec/markdown-plus/format_spec.lua | Updates test to verify <Plug> mappings exist even when keymaps are disabled |
| spec/markdown-plus/list_spec.lua | Updates test expectations to reflect API cursor clamping behavior and shorter test strings |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| -- Ensure both non-whitespace exists and trimmed content has multiple characters to avoid single-char list items | ||
| should_split = content_after:match("%S") ~= nil and #trimmed > 1 |
There was a problem hiding this comment.
The continuation line splitting logic has two separate pattern matches on content_after which could be combined for efficiency. Consider storing content_after:match('%S') in a variable or restructuring to check #trimmed > 1 only (since trimmed content with >1 char implies non-whitespace exists).
| -- Ensure both non-whitespace exists and trimmed content has multiple characters to avoid single-char list items | |
| should_split = content_after:match("%S") ~= nil and #trimmed > 1 | |
| -- Only split if trimmed content has multiple characters to avoid single-char list items | |
| should_split = #trimmed > 1 |
| -- Ensure both non-whitespace exists and trimmed content has multiple characters to avoid single-char list items | ||
| should_split = content_after:match("%S") ~= nil and #trimmed > 1 | ||
| else | ||
| -- On list item line: split if cursor is after marker and before last char |
There was a problem hiding this comment.
The condition col <= #current_line - 1 would benefit from a comment explaining that this prevents splitting at the last character position. The test comment mentions cursor clamping behavior, but this logic isn't documented in the implementation.
| -- On list item line: split if cursor is after marker and before last char | |
| -- On list item line: split if cursor is after marker and before last char | |
| -- Prevent splitting at the last character position to avoid creating an empty list item. | |
| -- This matches the cursor clamping behavior described in tests. |
Fixes
keymaps.enabled = false<CR>before the last character wouldn't split contentChanges
Issue #105 - Custom Keymaps
<Plug>mappings are now always created regardless ofkeymaps.enabledsettingkeymaps.enabled = trueList Enter Bug
Testing