Skip to content

Commit

Permalink
fix(command): update history during recompile in ship-mate buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
Walheimat committed Jun 11, 2024
1 parent 587518e commit 733f06f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ship-mate.el
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@ EDIT is passed as-is to all invocations of RECOMPILE."

(with-current-buffer (funcall-interactively recompile edit)

;; Update history.
(when-let ((command (car-safe compilation-arguments)))
(ship-mate-command--update-history cmd command t))

;; Needs to be re-set explicitly.
(setq ship-mate--this-command cmd)

Expand Down
17 changes: 15 additions & 2 deletions test/ship-mate-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -442,13 +442,16 @@

(let ((compile-history '("make test"))
(compile-command "make best")
(compilation-arguments nil)
(history (make-ring 2))
(matches nil))

(bydi ((:mock ship-mate-command--history :return history)
(bydi ((:othertimes ship-mate--command-buffer-p)
(:mock ship-mate-command--history :return history)
(:mock ship-mate-command--fuzzy-match :return matches)
(:mock ship-mate--local-value :return environment)
(:mock ship-mate-command--last-command :var last :initial nil)
ship-mate-command--update-history
ship-mate-command)

(ring-insert history "make history")
Expand All @@ -462,7 +465,17 @@

(ship-mate-command--capture #'ignore)

(bydi-was-called ship-mate-command))))
(bydi-was-called ship-mate-command)

(bydi-toggle-volatile 'ship-mate--command-buffer-p)

(setq compilation-arguments '("make recompile")
ship-mate--this-command 'test)

(ship-mate-command--capture (lambda (&rest _) (current-buffer)))

(bydi-was-called-with ship-mate-command--update-history
'(test "make recompile" t)))))

(ert-deftest ship-mate-command--capture--in-compilation-buffer ()
:tags '(command)
Expand Down

0 comments on commit 733f06f

Please sign in to comment.