branch: elpa/annotate commit 1350e1d0735e3937f9435c98dfdaf8a6c4bd2c00 Author: cage <cage@invalid> Commit: cage <cage@invalid>
- fixed annotated text shown in the summary window when an annotated buffer (that is visiting a file) is modified in a way that changes the position of an annotation in that buffer, showing the summary window -without saving the file first- will read the annotation using the updated position but getting the content from the outdated file; this gives wrong results in the text annotation parts of the summary windows, with the text shifted from the correct position. This patch try to fix this bug. --- annotate.el | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/annotate.el b/annotate.el index 9df2f5981e..6374d64d82 100644 --- a/annotate.el +++ b/annotate.el @@ -2470,6 +2470,20 @@ results can be filtered with a simple query language: see (info-setup filename (current-buffer)) (buffer-substring-no-properties annotation-begin annotation-end))) + (build-snippet-from-buffer (filename annotation-begin annotation-end) + (let ((visited-buffer (find-buffer-visiting filename))) + (when visited-buffer ;; a buffer is visiting the file + (with-current-buffer visited-buffer + (let ((raw-snippet (buffer-substring-no-properties annotation-begin + annotation-end))) + (clean-snippet raw-snippet)))))) + (build-snippet-from-file (filename annotation-begin annotation-end) + (with-temp-buffer + (insert-file-contents filename + nil + (1- annotation-begin) + (1- annotation-end)) + (clean-snippet (buffer-string)))) (build-snippet (filename annotation-begin annotation-end) (if (file-exists-p filename) (cond @@ -2479,12 +2493,12 @@ results can be filtered with a simple query language: see annotation-begin annotation-end))) (t - (with-temp-buffer - (insert-file-contents filename - nil - (1- annotation-begin) - (1- annotation-end)) - (clean-snippet (buffer-string))))) + (or (build-snippet-from-buffer filename + annotation-begin + annotation-end) + (build-snippet-from-file filename + annotation-begin + annotation-end)))) (if (annotate-info-root-dir-p filename) (clean-snippet (build-snippet-info filename annotation-begin