Sarcasm / irony-mode

A C/C++ minor mode for Emacs powered by libclang
GNU General Public License v3.0
906 stars 99 forks source link

Irony gives outdated (cached?) completion suggestions #456

Open frolosofsky opened 6 years ago

frolosofsky commented 6 years ago

Hi,

Thanks a lot for you work!

Unfortunately I experience troubles while using of irony, it seems irony doesn't refresh completion results properly. E.g. I have two functions: foo1 and foo2, at first time completion works well, after I add foo3, completion still shows only foo1 and foo2. But for some reason, after I call irony-get-type, it refreshes completion results. Let me provide you an example with logs given from irony server.

Given file:

void foo1(){}
void foo2(){}
// >>> here we will add foo3 <<<

int main() {
    // >>> here we will play with completion <<<
    return 0;
}

Step 1

Type foo, completions are foo1 and foo2.

execute: Command{action=Command::SetUnsaved, file='/Users/sfrolov/dev/tmp.cpp', unsavedFile='/var/folders/89/f505gpnn6bv3h2_ylrrrw1r00000gn/T/irony-unsaved-30182-h-', dir='', line=0, column=0, prefix='', caseStyle='exact', flags=[], opt=off}
execute: Command{action=Command::Complete, file='/Users/sfrolov/dev/tmp.cpp', unsavedFile='', dir='', line=7, column=5, prefix='', caseStyle='exact', flags=['-x', 'c++'], opt=off}
execute: Command{action=Command::Candidates, file='', unsavedFile='', dir='', line=0, column=0, prefix='foo', caseStyle='exact', flags=[], opt=off}
execute: Command{action=Command::Complete, file='/Users/sfrolov/dev/tmp.cpp', unsavedFile='', dir='', line=7, column=5, prefix='', caseStyle='exact', flags=['-x', 'c++'], opt=off}
execute: Command{action=Command::Candidates, file='', unsavedFile='', dir='', line=0, column=0, prefix='foo', caseStyle='exact', flags=[], opt=off}

Step 2

Add new function: void foo3(){}. Type foo, completions still are: foo1 and foo2. I expect too see foo3 there as well.

execute: Command{action=Command::ResetUnsaved, file='/Users/sfrolov/dev/tmp.cpp', unsavedFile='', dir='', line=0, column=0, prefix='', caseStyle='exact', flags=[], opt=off}
execute: Command{action=Command::Complete, file='/Users/sfrolov/dev/tmp.cpp', unsavedFile='', dir='', line=7, column=5, prefix='', caseStyle='exact', flags=['-x', 'c++'], opt=off}
execute: Command{action=Command::Candidates, file='', unsavedFile='', dir='', line=0, column=0, prefix='foo', caseStyle='exact', flags=[], opt=off}
execute: Command{action=Command::Complete, file='/Users/sfrolov/dev/tmp.cpp', unsavedFile='', dir='', line=7, column=5, prefix='', caseStyle='exact', flags=['-x', 'c++'], opt=off}
execute: Command{action=Command::Candidates, file='', unsavedFile='', dir='', line=0, column=0, prefix='foo', caseStyle='exact', flags=[], opt=off}

Step 3

Call M-x irony-get-type (on any symbol actually). Irony returns correct type.

execute: Command{action=Command::SetUnsaved, file='/Users/sfrolov/dev/tmp.cpp', unsavedFile='/var/folders/89/f505gpnn6bv3h2_ylrrrw1r00000gn/T/irony-unsaved-30182mZP', dir='', line=0, column=0, prefix='', caseStyle='exact', flags=[], opt=off}
execute: Command{action=Command::Parse, file='/Users/sfrolov/dev/tmp.cpp', unsavedFile='', dir='', line=0, column=0, prefix='', caseStyle='exact', flags=['-x', 'c++'], opt=off}
execute: Command{action=Command::GetType, file='', unsavedFile='', dir='', line=7, column=8, prefix='', caseStyle='exact', flags=[], opt=off}

The interesting difference I see in log is execute: Command{action=Command::Parse.

Step 4

Type foo, completions are: foo1, foo2, and foo3.

execute: Command{action=Command::SetUnsaved, file='/Users/sfrolov/dev/tmp.cpp', unsavedFile='/var/folders/89/f505gpnn6bv3h2_ylrrrw1r00000gn/T/irony-unsaved-30182zjV', dir='', line=0, column=0, prefix='', caseStyle='exact', flags=[], opt=off}
execute: Command{action=Command::Complete, file='/Users/sfrolov/dev/tmp.cpp', unsavedFile='', dir='', line=7, column=5, prefix='', caseStyle='exact', flags=['-x', 'c++'], opt=off}
execute: Command{action=Command::Candidates, file='', unsavedFile='', dir='', line=0, column=0, prefix='foo', caseStyle='exact', flags=[], opt=off}
execute: Command{action=Command::Complete, file='/Users/sfrolov/dev/tmp.cpp', unsavedFile='', dir='', line=7, column=5, prefix='', caseStyle='exact', flags=['-x', 'c++'], opt=off}
execute: Command{action=Command::Candidates, file='', unsavedFile='', dir='', line=0, column=0, prefix='foo', caseStyle='exact', flags=[], opt=off}

...

irony-get-type solves problem only one time, i.e. after adding void foo4(){} I don't see it until I call irony-get-type again.

Config

I use regular complete-symbol. I also tried to play with company-mode, with the same results actually. The version of package given from MELPA: irony-20171110.1151.

The .emacs config:

(add-hook 'c++-mode-hook 'irony-mode)
(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)
(eval-after-load 'company
  '(add-to-list 'company-backends 'company-irony))

Please let me know if I can help somehow with debugging.

nlsnightmare commented 6 years ago

Same problem here... only thing that seems to fix it is irony-get-type

ghost commented 6 years ago

Exactly the same here, pretty annoying problem.