diff options
author | Manuel Klimek <klimek@google.com> | 2016-10-25 11:31:22 +0000 |
---|---|---|
committer | Manuel Klimek <klimek@google.com> | 2016-10-25 11:31:22 +0000 |
commit | 63c6989d70ed1f94fc6a2a074fe703730e0a00a8 (patch) | |
tree | 6fe5af31a54127255c2e916fe4e6b9575a3e8bbd /clang-tools-extra/include-fixer | |
parent | 8e5f5ff4c1073bf8c6aeb2b628ea4b6a4b566f87 (diff) | |
download | bcm5719-llvm-63c6989d70ed1f94fc6a2a074fe703730e0a00a8.tar.gz bcm5719-llvm-63c6989d70ed1f94fc6a2a074fe703730e0a00a8.zip |
include-fixer: Don't overwrite buffer changes
Raise a signal if the buffer has been modified before replacing it, to
avoid overwriting users' changes.
Patch by Philipp Stephani.
llvm-svn: 285060
Diffstat (limited to 'clang-tools-extra/include-fixer')
-rw-r--r-- | clang-tools-extra/include-fixer/tool/clang-include-fixer.el | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/clang-tools-extra/include-fixer/tool/clang-include-fixer.el b/clang-tools-extra/include-fixer/tool/clang-include-fixer.el index ab7a59cea78..194f4b17f1f 100644 --- a/clang-tools-extra/include-fixer/tool/clang-include-fixer.el +++ b/clang-tools-extra/include-fixer/tool/clang-include-fixer.el @@ -244,7 +244,13 @@ clang-include-fixer to insert the selected header." (clang-include-fixer--select-header context) ;; Call clang-include-fixer again to insert the selected header. (clang-include-fixer--start - #'clang-include-fixer--replace-buffer + (let ((old-tick (buffer-chars-modified-tick))) + (lambda (stdout) + (when (/= old-tick (buffer-chars-modified-tick)) + ;; Replacing the buffer now would undo the user’s changes. + (user-error (concat "The buffer has been changed " + "before the header could be inserted"))) + (clang-include-fixer--replace-buffer stdout))) (format "-insert-header=%s" (clang-include-fixer--encode-json context))))))) nil) |