branch: externals/valign
commit cf4f9c966211936ac1ccb432c6ccabc4efcdac70
Author: Yuan Fu <[email protected]>
Commit: Yuan Fu <[email protected]>
* valign.el (valign-initial-alignment): Check buffer visibility.
---
valign.el | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/valign.el b/valign.el
index 643d852..d3a9a96 100644
--- a/valign.el
+++ b/valign.el
@@ -375,15 +375,19 @@ white space stretching to XPOS, a pixel x position."
"Perform initial alignment for tables between BEG and END.
Supposed to be called from jit-lock.
Force align if FORCE non-nil."
- (if (or force (text-property-any beg end 'valign-init nil))
- (save-excursion
- (goto-char beg)
- (while (and (search-forward "|" nil t)
- (< (point) end))
- (valign-table)
- (valign--end-of-table))
- (with-silent-modifications
- (put-text-property beg (point) 'valign-init t))))
+ ;; Technically we don’t need to check if the current buffer
+ ;; is visible, but third-party packages refontify buffers
+ ;; before they are visible, like org-superstart.
+ (when ((get-buffer-window (current-buffer))
+ (or force (text-property-any beg end 'valign-init nil)))
+ (save-excursion
+ (goto-char beg)
+ (while (and (search-forward "|" nil t)
+ (< (point) end))
+ (valign-table)
+ (valign--end-of-table))
+ (with-silent-modifications
+ (put-text-property beg (point) 'valign-init t))))
(cons 'jit-lock-bounds (cons beg end)))
(defun valign-always-align (beg end)