https://bugs.kde.org/show_bug.cgi?id=384710
            Bug ID: 384710
           Summary: "Magic function completion" ignores existing text
           Product: kdevelop
           Version: 5.1.2
          Platform: Gentoo Packages
                OS: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: NOR
         Component: Language Support: CPP (Clang-based)
          Assignee: kdevelop-bugs-n...@kde.org
          Reporter: alex.mur...@gmx.ch
  Target Milestone: ---

Overview
--------
I forget the exact name of this feature, but when you declare a function or a
member function in a header file and then partially type it in an
implementation file, the editor will "magically" produce suggestions for
autocompleting the declared function. In the old parser, this would replace the
text you had already typed with the new completion. In the new parser, it
ignores any text you have typed and just fills in the function, which in a lot
of cases is just wrong.

Steps to Reproduce
------------------
1) Create a header file with the following content

  void Foo(int thing);
  struct Bar
  {
      void Method(int thing);
  };

2) Create a .cpp file and type: "void Foo"
3) Wait, because the parser is now really slow
4) Finally, a suggestion for completing the "Foo" function pops up. Accept it.
5) Do the same for "Method" by typing "void Method" and accepting the
completion.

Actual Results
--------------
The resulting completions ignore the already typed "void" keyword and simply
insert the signatures, such that "void" now appears twice:

  void void Foo(int thing)
  {
  }

  void void Bar::Method(int thing)
  {
  }

If a project wishes to format the return type such that it appears on a new
line, then typing "void <new line> Foo" and accepting the suggestion produces
this incorrect completion:

  void 
  void Foo(int thing)
  {
  }

An even worse example of this: 
1) Begin typing "void Foo(int "
2) Press ctrl+space
3) Select "implement method Foo"
4) The completion creates this terrible snippet:

  Foo(int void Foo(int thing)
  {
  }
  )

Expected Results
----------------
The parser should be aware of the code that has already been typed and
remove/adjust it as necessary.

For the first example I expect the code to look like this after completion:

  void Foo(int thing)
  {
  }

  void Bar::Method(int thing)
  {
  }

For the second example:

  void 
  Foo(int thing)
  {
  }

And for the third example:

  void Foo(int thing)
  {
  }

Build Date & Platform
---------------------
Ever since the clang based parser was introduced.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to