Skip to content

Using function prototypes auto-completion has strange behavior #126

@braoult

Description

@braoult

Note: I use lsp-mode, ccls and flycheck.

Let say I have somewhere a C function int my_func(char *str, int num).

If I want to use it, I will start to type its name, let's say my_f, and I will be proposed the auto-complete choices:

my_func
my_func  (char *str, int num)

There is an issue if I select my_func (char *str, int num) ; The text is inserted in my buffer, then, after I replace the parameters with my own ones, ccls will always give errors on the line, which are very difficult to get rid of:
Even If I delete function name/parameters on the line, and re-type everything completely (function and parameters), the error will not disappear. It looks like ccls keeps some wrong status.
The only solution is to save then revert buffer, so that ccls "forgets" something about the inserted function declaration.
Killing the line (C-a C-k) works also.

It will be clearer with an example :

  1. Initial situation. I start to type a function name line 153, some choices are proposed.
    step 1
  2. I select the prototype.
    step 2
  3. After doing it, the text is inserted, with parameters highlighted.
    step 3
  4. I type the letter "i", the highlighted text is replaced with "i". Note that ccls looks unhappy with "i".
    step 4
  5. I complete the func call with a semicolon
    step 5
  6. After moving the cursor we can see there are likely 2 errors
    step 6
  7. Showing Flycheck all errors line 153, :
    step 7
  8. After deleting the function call (using "DEL" from EOL to first char function), an error remain on line.
    step 8
  9. Remaining Flycheck error on "empty" line
    step 9
  10. After "C-x C-s" and "M-x revert-buffer", the error is gone
    step 10

Feel free to ask if you need more information/testing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions