Closed hotpxl closed 6 years ago
Maybe related to #408 ?
Hello, thanks for the detailed explanation and solution. Reading your description and the code, I agree with the fix.
I'm wondering if the reset-unsaved
should be done old-state
's file, instead of relying on the new buffer's file, but I cannot come up with a problematic situation.
I think the question is, while old-state
and new-state
both have a file
field, they must be identical right? I'm not sure if moving a file in dired will cause any discrepancy.
I don't think they are necessarily identical.
I think, you can do things like C-x -Cw, aka write-file
, to target a new file for example.
set-visited-file-name
seems to be a setter for a buffer file.
Bug Reproduction
find-file
Environment
Emacs 26.1 RC1 (prebuilt by https://emacsformacosx.com/) macOS High Sierra Version 10.13.4
What Happens
Flycheck gives out the following error in
*Messages*
buffer:And the Irony log file has the following content:
My Analysis
When a buffer is not backed by a file on disk,
irony--buffer-state-compare
returnsset-unsaved
, andirony--unsaved-buffers-tasks
will sendset-unsaved
to the server, using-
as the file name. Kind of a hack here to make sure nothing is really done, since there is no file anyway.But the first time it is saved, the new state says the file is now unmodified, but was modified before. So the condition in
irony--buffer-state-compare
falls into the last case, and sends areset-unsaved
to the server. The server tries to remove the item from a map, but finding none (of course since the file was just created), hence the error.I added the check to make sure that only when old file exists, and the file changed from modified to unmodified, do we send
reset-unsaved
to the server.I'm not sure if I misunderstood the semantics of
unsaved
and broke some other stuff though.