Recent

Author Topic: Autocomplete-list suggesting names that do not fit in the current context  (Read 945 times)

prof7bit

  • Jr. Member
  • **
  • Posts: 85
[Edit: Translation below]

Hallo!

Ich benutze Lazarus zwar schon seit 0.9er Zeiten, manchmal jeden Tag, manchmal ein paar Monate gar nicht, aber heute ist mir was aufgefallen was mir bislang entgangen ist:

Durch ein sehr unbequem benanntes Enum war ich gezwungen heute ungewöhnlich viel Zeit in der Autocomplete-Dropdown-Liste zu verbringen und mir ist aufgefallen daß diese Liste (zumindest bei mir) nicht nach dem an der monentan befindlichen Position erlaubten Typ gefiltert ist. Das hat mich entweder noch nie gestört oder ich habe es nie bewußt wahrgenommen. Heute jedoch schon. Ich bekomme Vorschläge für so ziemlich jeden Bezeichner der an dieser Stelle sichtbar ist, jedoch würde ich erwarten daß die Liste irgendwie sinvoll gefiltert ist nach den Bezeichnern deren Typ an dieser Stelle überhaupt nur in Frage kommt, also entweder direkt ein Bezeichner dieses Typs oder irgendwas was ich dereferenzieren kann um evtl. indirekt an einen passenden Bezeichner dranzukommen, nicht jedoch offensichtlich komplett unpassende Typen wie zum Beispiel String oder Integer wenn ich eigentlich ein Enum brauche.

War das schon immer so, ist das Absicht oder hab ich bei mir was kaputtkonfiguriert?

---
Sorry, It seems I need to translate this (I mistakenly believed I was still in the German forum):

I have been using Lazarus since 0.9 but today for the first time I noticed something I have never noticed before:

Due to a very inconveniently named enum I had to spend much more time than usual in the autocomplete list today, trying to autocomplete on parts of my enum constant names. Before today I have never had the feeling something is wrong with this list but today the way it works made it very difficult for me to navigate the list for this particular task. When hiting Ctrl-Space the autocomplete dropdown the list will show every name that is visible in the current scope and it will not filter by the type that would actually be allowed in the current position. For example I am calling a function and it needs an enum of a certain type but it will suggest every name that is visible, including even completely nonsensical stuff like variables of type string or integer, or even worse other enums of different type but similar names, I would have expected to show only names of that exact enum type and then all names of objects that could theoretically be dereferenced to indirectly refer to something of the needed type, but not show me obviously wrong values that are neither the needed type nor can be dereferenced in any way.

Has it always been that way, is this intentoional or did I just mess up my configuration?

« Last Edit: March 16, 2021, 02:55:48 pm by prof7bit »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7414
  • Debugger - SynEdit - and more
    • wiki
Code completion can optional include simple word completion (IIRC that is also avail as ctrl-w)

Menu: Tools > Options > Codetools > Identifier completion
Line-Divider "Contents"
Checkbox "Include identifiers containing prefix" (it also has a dropdown)

prof7bit

  • Jr. Member
  • **
  • Posts: 85
Checkbox "Include identifiers containing prefix" (it also has a dropdown)
I already disabled this, the list has become shorter but it still contains hundreds of identifiers of all types from all over the entire project and all used units.
(see attached screenshot)

I am using 2.0.13 (fixes branch, compiled from svn every few days)
« Last Edit: March 16, 2021, 03:42:37 pm by prof7bit »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7414
  • Debugger - SynEdit - and more
    • wiki
I don't know the exact rules what will should be there, but...

Anything that is reachable (i.e. in this unit, or the interface of a unit that is in the uses)

Global vars (Form1) => seems ok,

the various "type" and "enum" => if they are reachable.

"unit", if they are in the use, they are valid. You can always write "unitname.something"
I do not know if it also lists units from used packages (kind of as "can be added")

 

TinyPortal © 2005-2018