瀏覽代碼

org-element-cache: Do not treat inserting newline at :begin sensitive

* lisp/org-element.el (org-element--cache-before-change): Do not match
`org-element--cache-sensitive-re' against an element starting at END
when END is at bol.  Such changes never break an element structure (as
opposed to inserting non-newline right at :begin of an element).
Ihor Radchenko 3 年之前
父節點
當前提交
fd93ad698a
共有 1 個文件被更改,包括 11 次插入1 次删除
  1. 11 1
      lisp/org-element.el

+ 11 - 1
lisp/org-element.el

@@ -6522,7 +6522,17 @@ The function returns the new value of `org-element--cache-change-warning'."
        (setq org-element--cache-change-tic (buffer-chars-modified-tick))
        (goto-char beg)
        (beginning-of-line)
-       (let ((bottom (save-excursion (goto-char end) (line-end-position))))
+       (let ((bottom (save-excursion
+                       (goto-char end)
+                       (if (bolp)
+                           ;; FIXME: Potential pitfall.
+                           ;; We are appending to an element end.
+                           ;; Unless the last inserted char is not
+                           ;; newline, the next element is not broken
+                           ;; and does not need to be purged from the
+                           ;; cache.
+                           end
+                         (line-end-position)))))
          (prog1
              (let ((org-element--cache-change-warning-before org-element--cache-change-warning)
                    (org-element--cache-change-warning-after))