Skip to content

Commit

Permalink
fix(command): require this-command to be non-nil
Browse files Browse the repository at this point in the history
  • Loading branch information
Walheimat committed Jun 23, 2024
1 parent 733f06f commit 7a2b86f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion ship-mate.el
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,8 @@ Optionally the PROJECT may be passed directly."
"Check if BUFFER is a `ship-mate-command' buffer."
(let ((buffer (or buffer (current-buffer))))

(string-match-p "\\*ship-mate" (buffer-name buffer))))
(and (string-match-p "\\*ship-mate" (buffer-name buffer))
(not (null ship-mate--this-command)))))

(defun ship-mate--command-buffer-predicate (buffer)
"Predicate to check if BUFFER is a `ship-mate' buffer.
Expand Down
2 changes: 2 additions & 0 deletions test/ship-mate-dinghy-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

(ert-with-test-buffer (:name "*ship-mate-maybe*")

(setq ship-mate--this-command 'test)

(ship-mate-dinghy--maybe-enable)

(bydi-was-called ship-mate-dinghy-mode)
Expand Down
5 changes: 4 additions & 1 deletion test/ship-mate-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,8 @@

(bydi ((:mock project-buffers :return (list a b))
(:mock buffer-list :return (list a b c))
(:always project-current))
(:always project-current)
(:mock ship-mate--command-buffer-p :with (lambda (it) (string-match-p "*ship-mate" (buffer-name it)))))

(should (eq (length (ship-mate-command--buffers)) 1))
(should (eq (length (ship-mate-command--buffers t)) 2)))
Expand Down Expand Up @@ -836,6 +837,8 @@

(rename-buffer "*ship-mate-buffer-pred")

(setq ship-mate--this-command 'test)

(should (ship-mate--command-buffer-predicate (cons "b" (current-buffer))))
(should (ship-mate--command-buffer-predicate (current-buffer))))))

Expand Down

0 comments on commit 7a2b86f

Please sign in to comment.