Skip to content

Commit

Permalink
Prevent automatic cursor movement caused by the command loop
Browse files Browse the repository at this point in the history
  • Loading branch information
kuranari committed Dec 5, 2023
1 parent 02a8b4e commit 309c90e
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions markdown-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -6558,7 +6558,12 @@ With argument N not nil or 1, move forward N - 1 lines first."
(when (and (= origin bol) (eq last-command this-command))
(goto-char refpos))
(when (or (> origin refpos) (<= origin bol))
(goto-char refpos)))))
(goto-char refpos)))
;; Prevent automatic cursor movement caused by the command loop.
;; Enable disable-point-adjustment to avoid unintended cursor repositioning.
(when (and markdown-hide-markup
(equal (get-char-property (point) 'display) ""))
(setq disable-point-adjustment t))))
((looking-at markdown-regex-list)
;; At a list item, special position is after the list marker or checkbox.
(let ((refpos (or (match-end 4) (match-end 3))))
Expand Down Expand Up @@ -6594,12 +6599,9 @@ With argument N not nil or 1, move forward N - 1 lines first."
(move-beginning-of-line n))
(cond
;; At a headline, with closing tags.
((and special
(save-excursion
(forward-line 0)
(and
(looking-at markdown-regex-header-atx)
(match-end 3))))
((save-excursion
(forward-line 0)
(and (looking-at markdown-regex-header-atx) (match-end 3)))
(let ((refpos (match-end 2))
(visual-end (and (bound-and-true-p visual-line-mode)
(save-excursion
Expand All @@ -6612,6 +6614,7 @@ With argument N not nil or 1, move forward N - 1 lines first."
(< visual-end refpos)
(<= origin visual-end))
(goto-char visual-end))
((not special) (end-of-line))
((eq special 'reversed)
(if (and (= origin (line-end-position))
(eq this-command last-command))
Expand All @@ -6620,7 +6623,12 @@ With argument N not nil or 1, move forward N - 1 lines first."
(t
(if (or (< origin refpos) (>= origin (line-end-position)))
(goto-char refpos)
(end-of-line))))))
(end-of-line))))
;; Prevent automatic cursor movement caused by the command loop.
;; Enable disable-point-adjustment to avoid unintended cursor repositioning.
(when (and markdown-hide-markup
(equal (get-char-property (point) 'display) ""))
(setq disable-point-adjustment t))))
((bound-and-true-p visual-line-mode)
(let ((bol (line-beginning-position)))
(end-of-visual-line)
Expand Down

0 comments on commit 309c90e

Please sign in to comment.