Skip to content

Commit 2aa6945

Browse files
committed
fix vc bug and test cases
1 parent b05ceab commit 2aa6945

File tree

4 files changed

+57
-2
lines changed

4 files changed

+57
-2
lines changed

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ test: compile
1616
-l test/test-utils.el \
1717
-l test/test-cmds.el \
1818
-l test/test-buffer.el \
19+
-l test/test-vc.el \
1920
--eval "(let (pop-up-windows) (ert t))"
2021

2122
test-batch: compile

neotree.el

+1-2
Original file line numberDiff line numberDiff line change
@@ -1178,8 +1178,7 @@ PATH is value."
11781178

11791179
(defun neo-buffer--insert-file-entry (node depth)
11801180
(let ((node-short-name (neo-path--file-short-name node))
1181-
(vc (or neo-vc-integration (neo-vc-for-node node)
1182-
?\s)))
1181+
(vc (when neo-vc-integration (neo-vc-for-node node))))
11831182
(insert-char ?\s (* (- depth 1) 2)) ; indent
11841183
(when (memq 'char neo-vc-integration)
11851184
(insert-char (car vc))

test/neotree-test.el

+11
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@
3131
(let ((default-directory temp-cwd)) ,@body)
3232
(delete-directory temp-cwd t))))
3333

34+
(defun neo-test--with-temp-dir-open ()
35+
(neo-test--with-temp-dir
36+
(write-region "" nil "file-1")
37+
(write-region "hello" nil "file-2")
38+
(neotree-dir temp-cwd)))
39+
40+
(defmacro neo-test--try-open (name &rest body)
41+
(declare (indent 0) (debug t))
42+
`(ert-deftest ,name ()
43+
,@body
44+
(neo-test--with-temp-dir-open)))
3445

3546
(provide 'neotree-test)
3647
;;; neotree-test.el ends here

test/test-vc.el

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
;;; test-vc.el --- test cases
2+
3+
;; Copyright (C) 2014 jaypei
4+
5+
;; Author: jaypei <[email protected]>
6+
;; URL: https://github.com/jaypei/emacs-neotree
7+
8+
;; This program is free software; you can redistribute it and/or modify
9+
;; it under the terms of the GNU General Public License as published by
10+
;; the Free Software Foundation, either version 3 of the License, or
11+
;; (at your option) any later version.
12+
13+
;; This program is distributed in the hope that it will be useful,
14+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
;; GNU General Public License for more details.
17+
18+
;; You should have received a copy of the GNU General Public License
19+
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
21+
;;; Commentary:
22+
23+
;;; Code:
24+
25+
(require 'neotree)
26+
(require 'neotree-test)
27+
28+
(neo-test--try-open
29+
neo-test-vc-mode-with-face
30+
(shell-command-to-string "git init")
31+
(setq neo-vc-integration '(face)))
32+
33+
(neo-test--try-open
34+
neo-test-vc-mode-with-char
35+
(shell-command-to-string "git init")
36+
(setq neo-vc-integration '(char)))
37+
38+
(neo-test--try-open
39+
neo-test-vc-mode-with-char-face
40+
(shell-command-to-string "git init")
41+
(setq neo-vc-integration '(char face)))
42+
43+
44+
;;; test-vc.el ends here

0 commit comments

Comments
 (0)