Show suggestions when typing? lazarus / 9-Editor ---------------------------------------------------------------------- duzenko · 2023-08-23 15:26 Is there any way to get suggestions show when typing without having to Ctrl+Space every single word? ---------------------------------------------------------------------- Eugene Loza · 2023-08-23 15:40 I think this is what you are looking for: ---------------------------------------------------------------------- Martin_fr · 2023-08-23 16:55 Tools >  Opions. Codetools > Identifier Completion There is a checkbox (top of the page): "Automatically invoke on typing" You can make it, that it only opens when you make a brief pause while typing (but no dot required) "Use completion box delay". Or leave that unchecked, and always get it. You can set it, that you must type at least n letters into a word. ----- You may want to also check "Include all keywords and operators". So you also get "begin", "end", "repeat", ...., "and", "or", ... ---------------------------------------------------------------------- duzenko · 2023-08-23 17:45 Quote from: Martin_fr on August 23, 2023, 06:55:08 pmTools >  Opions. Codetools > Identifier Completion There is a checkbox (top of the page): "Automatically invoke on typing" You can make it, that it only opens when you make a brief pause while typing (but no dot required) "Use completion box delay". Or leave that unchecked, and always get it. You can set it, that you must type at least n letters into a word. ----- You may want to also check "Include all keywords and operators". So you also get "begin", "end", "repeat", ...., "and", "or", ... Thanks, this is it It's a little frustrating that it's not on by default - and there's two separate options tabs for it ---------------------------------------------------------------------- Martin_fr · 2023-08-23 18:14 I agree some options (including this one) are hard to find, due to being split across pages. There is some internal issue that (afaik) prevents to "just move the checkbox to the other frame" . Though I might be wrong. Not everyone likes that feature, I had other editors that had it on by default - and I spent a lot of time figuring out how to disable it (or find an alternative editor). ---------------------------------------------------------------------- duzenko · 2023-08-25 10:17 Quote from: Martin_fr on August 23, 2023, 06:55:08 pmYou may want to also check "Include all keywords and operators". So you also get "begin", "end", "repeat", ...., "and", "or", ... Sorry, where do I find this option? Can't see it on either of the two tabs in 2.2.6? I do miss it sorely, e.g. when typing loops, etc ---------------------------------------------------------------------- Martin_fr · 2023-08-25 12:23 Image is 3.0RC I don't have 2.2.6 at hand. IIRC the option exists in 2.2.6 too. (3.0 may have improvements on it / not sure) ---------------------------------------------------------------------- duzenko · 2023-08-26 07:52 Thanks, I upgraded to 3.0RC1 just to be on the same page I enabled the all keywords options but it's still not exactly correct Simple case: the 'to' keyword is not in the suggestions list ---------------------------------------------------------------------- Martin_fr · 2023-08-26 09:25 Quote from: duzenko on August 26, 2023, 09:52:56 amThanks, I upgraded to 3.0RC1 just to be on the same page I enabled the all keywords options but it's still not exactly correct Simple case: the 'to' keyword is not in the suggestions list 1) If I type "for a := StartIndex " then it is in the list (though a lot of other keywords are before it) 2) But yes, if I type  "for a := 1 " (a literal number), then it is not in the list. So that is a bug. ---------------------------------------------------------------------- Martin_fr · 2023-08-26 09:41 Below patch will get you the "to" It will however get it in a lot of places.... including where it does not belong. This is not a fix. At least not the correct fix (so this will not get commited to the official sources). Just a quick: if you really need it now. Report it as a bug, maybe someone else has time for it... I have (unfortunately for this issue) a huge todo list in front of me. Code: Diff  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i diff --git a/components/codetools/identcompletiontool.pas b/components/codetools/identcompletiontool.pasindex df2434c934..896e4337c6 100644--- a/components/codetools/identcompletiontool.pas+++ b/components/codetools/identcompletiontool.pas@@ -2334,17 +2334,20 @@ procedure TIdentCompletionTool.GatherContextKeywords(             Add('with');           end;           if (ilcfStartInStatement in CurrentIdentifierList.ContextFlags)-          and not (ilcfStartOfOperand in CurrentIdentifierList.ContextFlags)           and (CurrentIdentifierList.StartBracketLvl = 0)           then begin-            Add('else');-            Add('end');-            Add('then');-            Add('do');-            Add('downto');-          Add('of');-            Add('on');-            Add('to');+          if not (ilcfStartOfOperand in CurrentIdentifierList.ContextFlags) then begin+              Add('else');+              Add('end');+            Add('then');+              Add('do');+              Add('downto');+              Add('of');+              Add('on');+            Add('to');+            end+            else+              Add('to');           end;           if (ilcfStartOfStatement in CurrentIdentifierList.ContextFlags)           or (CurrentIdentifierList.ContextFlags * [ilcfStartInStatement, ilcfStartOfOperand] = [ilcfStartInStatement, ilcfStartOfOperand]) ---------------------------------------------------------------------- duzenko · 2023-08-27 09:53 Thanks, raised new issue https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40468 ---------------------------------------------------------------------- Martin_fr · 2023-08-27 13:15 Quote1. Some keywords do not show up in the list (e.g. `to` in this case) 2. currently typed identifier should always be first in the list, i.e. if I type `to` then it should be the first in the list, not `TObject` 3. Local variables should come before everything non-local 4. When in class methods, this class methods and fields should come before anything external 5. (Ideally) no suggestions when declaring new variable/type names (2) should be the case already? (I mean for identifiers that are in the list: If you typed "TFoo" it will be on the top, even if there is a "TFooBar" that would show at higher priority (i.e. for "TFo" the suggestions would have been: TFooBar and after that TFoo. If you mean, when you have Typed "TObj" but there is no "TOBj" in the list (it is not a known identifier) => then the current "partial word at cursor" should be added to the list (always) => then that may not be clear to the reader. (At least it wasn't to me) (3)  What is your "Order by" setting? If you have "Alphabetic (Scoped)" or (in Lazarus 3.0) "Definition(Scoped)" then that should be the case. => Note: parameters are considered the same as local vars. If you mean "variables from a local var block, then parameters, then ..." => maybe change your description. Mind also, that anything that matches the prefix at the very start of the suggestion (suggestion starts same as prefix) will always be on top of anything that has the prefix (only) somewhere in the middle of the suggestion. If that should be different, then maybe make that an extra note. (4) should be the same as 3. IIRC any "scoped order" goes - local (local var and parameters / also local types, const, labels,...) - Anything from the class - inherited from parent - inherited from 2nd parent / and so on - current unit (I think this is next, would need to double check) - ... Mind that keywords are currently sorted at highest scope. (internally they are a different group than the above list). So if your suggestion is meant to affect the position of keywords too, may be worth mention (As any one working on the internals of the code may miss it, due to internal different meaning of the words used) ---------------------------------------------------------------------- duzenko · 2023-08-29 08:59 Quote(2) should be the case already? (I mean for identifiers that are in the list: If you typed "TFoo" it will be on the top, even if there is a "TFooBar" that would show at higher priority (i.e. for "TFo" the suggestions would have been: TFooBar and after that TFoo. At least not always - would you need a repro case? Quote(3)  What is your "Order by" setting? (4) should be the same as 3. Thanks, I'll give it a try. If it does the job then it should be considered to be the default config ---------------------------------------------------------------------- Martin_fr · 2023-08-30 08:17 Quote from: duzenko on August 29, 2023, 10:59:13 amQuote(2) should be the case already? (I mean for identifiers that are in the list: If you typed "TFoo" it will be on the top, even if there is a "TFooBar" that would show at higher priority (i.e. for "TFo" the suggestions would have been: TFooBar and after that TFoo. At least not always - would you need a repro case? I *guess* I know what you mean. But I am not right no going to work on this. And if someone else works on your report, they may not know. You have seen some-one else has asked a very similar question on the issue you reported. Your description gets mistaken for something else (if my guess is correct). Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  TFoo: boolean; // global, could even be in a different unitprocedure Bar;var   TFooBar: integer;begin  T Complete after the "T" There is no "T" on top of the list, if you type "TF" there is no "TF" on top of the list.... If you type "TF" => you get (assuming you have scoped ordering) - TFooBar because it is local and comes first - TFoo   which is not local and comes 2nd But if you type "TFoo", then the "TFoo" in the list will be the first/topmost entry. Because it is an exact/identical match. So when you write Quotecurrently typed identifier should always be first in the list, i.e. if I type `to` then it should be the first in the list, not `TObject`other people think of "existing identifier" => if there already is an identifier, that is exactly the same as what you are typing, then show that identifier on top. But (I GUESS) what you mean is. => whatever partial identifier you have just typed, even if that does not yet exist anywhere else in the source, show that on top (so that when you press space, you always get what you have typed, and never some other completion. If that is what you mean, then make it clear on the issue report. The completion/suggestion was originally only for ctrl-space or when you typed a "." => in those cases most people wanted to chose from the list, and it was not needed to have the "current word fragment" in the list (afaik this is intentionally kept out of the list). The complete always while you type is relatively new. It was contributed by another user. And it is in exactly the state in which it has been contributed. (So yes it probably still needs some work) ---------------------------------------------------------------------- duzenko · 2023-09-12 13:00 Quote=> whatever partial identifier you have just typed, even if that does not yet exist anywhere else in the source, show that on top (so that when you press space, you always get what you have typed, and never some other completion. No, I meant existing identifiers of course It does not make sense to suggest non-existent items ---------------------------------------------------------------------- Martin_fr · 2023-09-12 14:09 Quote from: duzenko on September 12, 2023, 03:00:20 pmQuote=> whatever partial identifier you have just typed, even if that does not yet exist anywhere else in the source, show that on top (so that when you press space, you always get what you have typed, and never some other completion. No, I meant existing identifiers of course It does not make sense to suggest non-existent items Then I am at loss what you mean. As I understand it, it already works that way. I have my completion list sorted "Alphabetic (Scoped)". So when I complete in the below Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Project1;var FooBar: integer;procedure p1;var  FooBarLocal: integer;begin  Fooba   // Completing hereend; beginend. The list shows (locals before globals) Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i FooBarLocalFooBar But as soon as I type the missing "r" my "currently typed identifier" will be "FooBar" Quote2. currently typed identifier should always be first in the list, i.e. if I type `to` then it should be the first in the list, not `TObject` "FooBar" exists, and the entry for the existing  "FooBar" is the first in the list. Of course that only works, if the word is in the list. You are testing with the keyword "to", which in your case is (due to a different bug) not in the list. If it isn't in the list, it can't be on top of the list. But the question is, if "for any word that is in the list" the "current" is not shown on top?