Andersbakken / rtags

A client/server indexer for c/c++/objc[++] with integration for Emacs based on clang.
http://www.rtags.net
GNU General Public License v3.0
1.83k stars 252 forks source link

rtags-apply-fixit-at-point doesn't work #1129

Closed JohnC32 closed 6 years ago

JohnC32 commented 6 years ago

Please mark appropriate

Problem description

The `rtags-apply-fixit-at-point' function doesn't work. To test, compile a c++ file with -Weverything, then use NULL (it should be nullptr). There will be a fixit shown using the rtags-fixitline face. Running rtags-apply-fixit-at-point when point is on the NULL will do nothing.

I glanced at the code and don't see how it could work:

(defun rtags-apply-fixit-at-point ()
  (interactive)
  (let ((line (buffer-substring-no-properties (point-at-bol) (point-at-eol))))
    (when (string-match "^\\(.*\\):[0-9]+:[0-9]+: fixit: \\([0-9]+\\)-\\([0-9]+\\): .*did you mean '\\(.*\\)'\\?$" line)

line is content from the file.cpp and not the clang diagnostic. Also, elsewhere in rtags.el the 'did you mean' was stripped from the message.

It would also be good to keep the 'did you mean' in the diagnostic message when shown by rtags-diagnostics (this makes it easier to read the message).

Expected behavior

Running `rtags-apply-fixit-at-point' should work.

Actual behavior

Fixit is not applied.

Environment

casch-at commented 6 years ago

Hey @JohnC32, rtags-fix-fixit-at-point is the function doing the work, and is now (again) bound to C-c r X. I removed rtags-apply-fixit-at-point completely.