Skip to content

Commit

Permalink
[Git] Update containing dirs' git status when deleting & creating files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Miller committed Sep 23, 2023
1 parent 56691a5 commit 78380db
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/elisp/treemacs-async.el
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ DEFAULT: Face"
"Saves the specific version of git-mode that is active.
Values are either `simple', `extended', `deferred' or nil.")

(defun treemacs--non-simple-git-mode-enabled ()
"Indicate whether a version of git-mode is enabled that affects directories."
(declare (side-effect-free t))
(memq treemacs--git-mode '(deferred extended)))

(defun treemacs--resize-git-cache ()
"Cuts `treemacs--git-cache' back down to size.
Specifically its size will be reduced to half of `treemacs--git-cache-max-size'."
Expand Down
6 changes: 5 additions & 1 deletion src/elisp/treemacs-core-utils.el
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@

(treemacs-import-functions-from "treemacs-async"
treemacs--git-status-process
treemacs--non-simple-git-mode-enabled
treemacs-update-single-file-git-state
treemacs--collapsed-dirs-process)

(treemacs-import-functions-from "treemacs-dom"
Expand Down Expand Up @@ -475,7 +477,9 @@ being edited to trigger."
;; filewatch mode needs the node's information to be in the dom
(unless (with-no-warnings treemacs-filewatch-mode)
(treemacs-run-in-every-buffer
(treemacs-on-collapse ,path t)))))))
(treemacs-on-collapse ,path t)))
(when (treemacs--non-simple-git-mode-enabled)
(treemacs-update-single-file-git-state (treemacs--parent-dir ,path)))))))

(define-inline treemacs--refresh-dir (path &optional project)
"Local refresh for button at PATH and PROJECT.
Expand Down
11 changes: 8 additions & 3 deletions src/elisp/treemacs-file-management.el
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
(require 'treemacs-logging)
(require 'treemacs-rendering)
(require 'treemacs-annotations)
(require 'treemacs-async)

(eval-when-compile
(require 'inline)
Expand Down Expand Up @@ -540,9 +541,13 @@ IS-FILE?: Bool"
;; update only the part that changed to keep things smooth
;; for files that's just their parent, for directories we have to take
;; flattening into account
(if (treemacs-button-get created-under-btn :collapsed)
(treemacs-update-node (treemacs-button-get (treemacs-button-get created-under-btn :parent) :path))
(treemacs-update-node (treemacs-button-get created-under-btn :path))))
(-let [path-to-update
(if (treemacs-button-get created-under-btn :collapsed)
(treemacs-button-get (treemacs-button-get created-under-btn :parent) :path)
(treemacs-button-get created-under-btn :path))]
(treemacs-update-node path-to-update)
(when (treemacs--non-simple-git-mode-enabled)
(treemacs-update-single-file-git-state path-to-update))))
(treemacs-goto-file-node path-to-create project)
(recenter))
(treemacs-pulse-on-success
Expand Down
2 changes: 1 addition & 1 deletion src/elisp/treemacs-rendering.el
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ DIRS: List of Collapse Paths. Each Collapse Path is a list of
(-let [beg (point)]
(insert label-to-add)
(add-text-properties beg (point) props)
(unless (memq treemacs--git-mode '(deferred extended))
(unless (treemacs--non-simple-git-mode-enabled)
(add-text-properties
beg (point)
'(face treemacs-directory-collapsed-face)))))))))))
Expand Down

0 comments on commit 78380db

Please sign in to comment.