github saberzero1/motions 0.26.0

latest releases: 1.4.0, 1.3.1, 1.3.0...
3 months ago

Fixed

  • Stale jumpList markers crash vim state on document switch — gg, G, and other motions with toJumplist: true threw RangeError: Invalid position N in document of length M when switching between documents of different lengths (especially with PDF++ plugin). The global jumpList stored Marker objects with absolute offsets from the previous (longer) document. When jumpList.add() called curMark.find() on a stale marker, posFromIndex passed the old offset to doc.lineAt() without bounds checking, crashing through processMotion → processCommand → the cm.operation() try-catch, which wiped and re-initialized vim state. Subsequent keystrokes fell through to default CM6 text insertion. (#18)
    • Fork: posFromIndex now clamps offset to [0, doc.length], mirroring indexFromPos bounds checking
    • Fork: Marker.find() catches exceptions and returns null for stale markers (all callers already handle null)
    • Fork: Marker.update() catches RangeError from mapPos() when marker offset exceeds the changeset's starting document length, setting offset = null
    • Plugin: reloadFeatures() now calls vim.resetKeymap() to match onload() behavior, closing a defense gap where 33 settings-triggered reloads could corrupt the keymap without recovery
    • 5 new fork tests (posFromIndex clamping, negative offset, valid offset, marker doc-shrink, gg/G with stale jumpList)
    • 3 new plugin e2e tests (gg after doc switch, G after doc switch, gg/G after reloadFeatures on shorter doc)
  • Visual line mode (V) highlight doesn't match Obsidian theme — the linewise selection highlight used hardcoded rgba colors via the fork's EditorView.baseTheme, which didn't adapt to Obsidian themes. The fork's &light/&dark CSS variants never activated because Obsidian doesn't add cm-dark/cm-light classes to .cm-editor. Added a CSS override in styles.css using var(--text-selection) (Obsidian's accent-derived selection color) at specificity 0-3-0, which beats both the fork's base theme (0-2-0) and Obsidian's code block background (0-2-1) without !important. (#38)
  • Visual line mode highlight invisible inside code blocks — the linewise selection Decoration.line() class competed with Obsidian's HyperMD-codeblock-bg class on the same .cm-line element. The code block background (applied at specificity 0-2-1 via .cm-s-obsidian div.HyperMD-codeblock-bg) won the specificity fight. Fixed by the same CSS override above — specificity 0-3-0 beats 0-2-1. (#38)
  • Visual block select (Ctrl-V) on EOL displaces cursor rightward — makeCmSelection in the fork's block mode branch added +1 to toCh for inclusive selection without per-line clamping. When $ (end-of-line) set toCh to the actual line length, toCh + 1 pushed the cursor one position past the last character. Fixed by clamping toCh and fromCh to each line's length inside the per-line loop, since each line in a block selection has a different length. The $ motion's Infinity return for ch is preserved upstream — clamping only happens at the selection-building stage. (#38)
  • Formatting mark transaction filter corrupts visual selections — the EditorState.transactionFilter in formatting-mark-fix.ts snapped cursor positions past formatting marks (**, *, `, ~~, ==) for all selection changes, including visual mode selections. When extending a visual selection across formatted text in Live Preview, the filter's snapRange function modified the selection head to a formatting mark boundary, causing the selection to jump or collapse unexpectedly. Fixed by adding a range.empty guard that skips snapping for non-empty (visual) selections — the formatting mark correction is only needed for normal-mode cursor movement. (#38)
    • Fork: makeCmSelection block mode now clamps toCh/fromCh per-line via lineLength(cm, top + i)
    • Plugin: formatting-mark-fix.ts skips snapRange when range.empty is false
    • Plugin: styles.css adds .cm-editor .cm-line.cm-vim-linewise-selection override with var(--text-selection) fallback chain
  • Visual block $ delete cursor deviation — <C-v>jj$d leaves cursor at ch:1 instead of Neovim's ch:0 after deleting to EOL. This is a pre-existing cursor-after-block-delete positioning issue in the fork (content is correct, only cursor position differs). Registered as a known deviation in test/neovim/deviations.ts.

Documentation

  • KNOWN_LIMITATIONS.md: updated "Formatting mark cursor correction in Live Preview" section to document the visual mode bypass
  • KNOWN_LIMITATIONS.md: updated "Block visual mode" section test coverage count (13 → 15 golden tests)
  • DIFFERENCES.md (fork): added "Block visual EOL cursor clamping" section documenting makeCmSelection per-line clamp
  • README.md: updated recommended setup to mention theme-aligned visual line highlighting

Full Changelog: 0.25.0...0.26.0

Don't miss a new motions release

NewReleases is sending notifications on new releases.