branch: elpa/dart-mode
commit caa7a19a8719dc2adfd952a84776c2f88ee3776f
Author: Natalie Weizenbaum <[email protected]>
Commit: Natalie Weizenbaum <[email protected]>

    Don't error out with revert-buffer
---
 dart-mode.el | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/dart-mode.el b/dart-mode.el
index 832d241..4584d94 100644
--- a/dart-mode.el
+++ b/dart-mode.el
@@ -833,13 +833,16 @@ Initializes analysis server support for all `dart-mode' 
buffers."
 The Dart analysis server allows clients to 'overlay' file contents with
 a client-supplied string.  This is needed because we want Emacs to report
 errors for the current contents of the buffer, not whatever is saved to disk."
-  (dart--analysis-server-send
-   "analysis.updateContent"
-   `((files .
-            ((,buffer-file-name . ((type . "add")
-                                   (content . ,(save-restriction
-                                                 (widen)
-                                                 (buffer-string))))))))))
+  ;; buffer-file-name can be nil within revert-buffer, but in that case the
+  ;; buffer is just being reverted to its format on disk anyway.
+  (when buffer-file-name
+    (dart--analysis-server-send
+     "analysis.updateContent"
+     `((files .
+              ((,buffer-file-name . ((type . "add")
+                                     (content . ,(save-restriction
+                                                   (widen)
+                                                   (buffer-string)))))))))))
 
 (defun dart-change-analysis-overlay
     (change-begin change-end change-before-length)

Reply via email to