Address code review feedback: improve comments and test cleanup
Co-authored-by: Kinneyzhang <38454496+Kinneyzhang@users.noreply.github.com>
This commit is contained in:
parent
d176d2e7cb
commit
6d34267f1c
@ -2845,8 +2845,11 @@ incorrectly generate an anonymous tp-name instead of using the layer name."
|
|||||||
(ert-deftest tp-test-redefine-layer-updates-watchers ()
|
(ert-deftest tp-test-redefine-layer-updates-watchers ()
|
||||||
"Test that re-defining a layer updates :watch correctly."
|
"Test that re-defining a layer updates :watch correctly."
|
||||||
(tp-test-with-temp-buffer
|
(tp-test-with-temp-buffer
|
||||||
|
;; Use defvar to create dynamically-bound variables that watcher callbacks can access
|
||||||
(defvar tp-test-watch-log-old nil "Log for old watcher.")
|
(defvar tp-test-watch-log-old nil "Log for old watcher.")
|
||||||
(defvar tp-test-watch-log-new nil "Log for new watcher.")
|
(defvar tp-test-watch-log-new nil "Log for new watcher.")
|
||||||
|
(setq tp-test-watch-log-old nil)
|
||||||
|
(setq tp-test-watch-log-new nil)
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(progn
|
(progn
|
||||||
;; First definition with old watcher
|
;; First definition with old watcher
|
||||||
@ -2968,8 +2971,8 @@ incorrectly generate an anonymous tp-name instead of using the layer name."
|
|||||||
:props (face (:background $tp-test-applied-color))
|
:props (face (:background $tp-test-applied-color))
|
||||||
:data ((tp-test-applied-color . "blue")))
|
:data ((tp-test-applied-color . "blue")))
|
||||||
;; The text should now have the new color
|
;; The text should now have the new color
|
||||||
;; Note: This happens because re-definition updates the variable,
|
;; This happens because tp-define-layer calls tp--update-layer-regions
|
||||||
;; which triggers the reactive update mechanism
|
;; at the end to update all text regions with the new properties
|
||||||
(should (equal (plist-get (get-text-property 1 'face) :background) "blue")))
|
(should (equal (plist-get (get-text-property 1 'face) :background) "blue")))
|
||||||
;; Cleanup
|
;; Cleanup
|
||||||
(ignore-errors (makunbound 'tp-test-applied-color)))))
|
(ignore-errors (makunbound 'tp-test-applied-color)))))
|
||||||
|
|||||||
12
tp.el
12
tp.el
@ -2072,7 +2072,7 @@ The layer is stored in `tp-layer-alist'."
|
|||||||
(if (or all-reactive-syms data compute)
|
(if (or all-reactive-syms data compute)
|
||||||
;; Has reactive features - register dependencies and resolve at runtime
|
;; Has reactive features - register dependencies and resolve at runtime
|
||||||
`(progn
|
`(progn
|
||||||
;; Clean up old dependencies first (for re-definition)
|
;; Clean up old reactive dependencies, watchers, computed properties, and data (for re-definition)
|
||||||
(tp--unregister-reactive-deps ',name)
|
(tp--unregister-reactive-deps ',name)
|
||||||
;; Ensure all reactive variables are defined
|
;; Ensure all reactive variables are defined
|
||||||
(tp--ensure-reactive-variables ',all-vars-to-define)
|
(tp--ensure-reactive-variables ',all-vars-to-define)
|
||||||
@ -2098,7 +2098,7 @@ The layer is stored in `tp-layer-alist'."
|
|||||||
(assoc ',name tp-layer-alist))
|
(assoc ',name tp-layer-alist))
|
||||||
;; No reactive symbols - use static properties
|
;; No reactive symbols - use static properties
|
||||||
`(progn
|
`(progn
|
||||||
;; Clean up old dependencies first (for re-definition from reactive to non-reactive)
|
;; Clean up old reactive dependencies, watchers, computed properties, and data (for re-definition)
|
||||||
(tp--unregister-reactive-deps ',name)
|
(tp--unregister-reactive-deps ',name)
|
||||||
(tp--set-layer-props ',name ',properties)
|
(tp--set-layer-props ',name ',properties)
|
||||||
;; Update any text regions that already have this layer applied
|
;; Update any text regions that already have this layer applied
|
||||||
@ -2265,7 +2265,7 @@ and the group itself is stored in `tp-layer-groups'."
|
|||||||
(if (or all-reactive-syms data compute)
|
(if (or all-reactive-syms data compute)
|
||||||
;; Has reactive features - register dependencies and resolve at runtime
|
;; Has reactive features - register dependencies and resolve at runtime
|
||||||
(push `(progn
|
(push `(progn
|
||||||
;; Clean up old dependencies first (for re-definition)
|
;; Clean up old reactive dependencies, watchers, computed properties, and data (for re-definition)
|
||||||
(tp--unregister-reactive-deps ',layer-name)
|
(tp--unregister-reactive-deps ',layer-name)
|
||||||
;; Ensure all reactive variables are defined
|
;; Ensure all reactive variables are defined
|
||||||
(tp--ensure-reactive-variables ',all-vars-to-define)
|
(tp--ensure-reactive-variables ',all-vars-to-define)
|
||||||
@ -2290,7 +2290,7 @@ and the group itself is stored in `tp-layer-groups'."
|
|||||||
layer-defs)
|
layer-defs)
|
||||||
;; No reactive symbols - use static properties
|
;; No reactive symbols - use static properties
|
||||||
(push `(progn
|
(push `(progn
|
||||||
;; Clean up old dependencies first (for re-definition)
|
;; Clean up old reactive dependencies, watchers, computed properties, and data (for re-definition)
|
||||||
(tp--unregister-reactive-deps ',layer-name)
|
(tp--unregister-reactive-deps ',layer-name)
|
||||||
(tp--set-layer-props ',layer-name ',props)
|
(tp--set-layer-props ',layer-name ',props)
|
||||||
;; Update any text regions that already have this layer applied
|
;; Update any text regions that already have this layer applied
|
||||||
@ -2305,7 +2305,7 @@ and the group itself is stored in `tp-layer-groups'."
|
|||||||
(if reactive-syms
|
(if reactive-syms
|
||||||
;; Has reactive symbols - register dependencies and resolve at runtime
|
;; Has reactive symbols - register dependencies and resolve at runtime
|
||||||
(push `(progn
|
(push `(progn
|
||||||
;; Clean up old dependencies first (for re-definition)
|
;; Clean up old reactive dependencies, watchers, computed properties, and data (for re-definition)
|
||||||
(tp--unregister-reactive-deps ',layer-name)
|
(tp--unregister-reactive-deps ',layer-name)
|
||||||
(tp--ensure-reactive-variables
|
(tp--ensure-reactive-variables
|
||||||
',(mapcar #'tp--reactive-var-symbol reactive-syms))
|
',(mapcar #'tp--reactive-var-symbol reactive-syms))
|
||||||
@ -2318,7 +2318,7 @@ and the group itself is stored in `tp-layer-groups'."
|
|||||||
layer-defs)
|
layer-defs)
|
||||||
;; No reactive symbols - use static properties
|
;; No reactive symbols - use static properties
|
||||||
(push `(progn
|
(push `(progn
|
||||||
;; Clean up old dependencies first (for re-definition)
|
;; Clean up old reactive dependencies, watchers, computed properties, and data (for re-definition)
|
||||||
(tp--unregister-reactive-deps ',layer-name)
|
(tp--unregister-reactive-deps ',layer-name)
|
||||||
(tp--set-layer-props ',layer-name ',props)
|
(tp--set-layer-props ',layer-name ',props)
|
||||||
;; Update any text regions that already have this layer applied
|
;; Update any text regions that already have this layer applied
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user