Recent

Author Topic: v3.99 code completion question  (Read 4117 times)

440bx

  • Hero Member
  • *****
  • Posts: 4727
v3.99 code completion question
« on: April 20, 2024, 12:45:55 am »
Please refer to the screenshot.

In line 3136, the editor changed "char" to "Char".  I'd like the editor to not change anything I type (even if it's wrong... I'll fix it myself) but, I couldn't find the setting that tells the editor to leave my code alone.

In line 3137, the editor suggests "ArrayStringToPPchar" and no matter what I type next it puts that "ArrayStringToPPchar" string in there.  I'd like the editor to put whatever it is suggesting only if I press "enter" or possibly "tab" and _nothing_ for any other key.  Right now, it puts that string in there no matter what I type.

Thank you for your help.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

VisualLab

  • Hero Member
  • *****
  • Posts: 569
Re: v3.99 code completion question
« Reply #1 on: April 20, 2024, 03:12:27 pm »
Please refer to the screenshot.

In line 3136, the editor changed "char" to "Char".  I'd like the editor to not change anything I type (even if it's wrong... I'll fix it myself) but, I couldn't find the setting that tells the editor to leave my code alone.

In line 3137, the editor suggests "ArrayStringToPPchar" and no matter what I type next it puts that "ArrayStringToPPchar" string in there.  I'd like the editor to put whatever it is suggesting only if I press "enter" or possibly "tab" and _nothing_ for any other key.  Right now, it puts that string in there no matter what I type.

Thank you for your help.

I tried to replicate behaviour of Lazarus by entering the code provided in the screenshot. But I didn't notice the behavior you described. I'm using Lazarus 3.0 (64-bit), Windows 10 (64-bit). So it's probably some option that is enabled in your IDE, but disabled in mine.

Unless this applies to a newer version of Lazarus. In any case, this is a disturbing behavior of the IDE, because the editor should be helpful and not "a pompous wise guy who knows better than the programmer".
« Last Edit: April 20, 2024, 04:15:47 pm by VisualLab »

440bx

  • Hero Member
  • *****
  • Posts: 4727
Re: v3.99 code completion question
« Reply #2 on: April 20, 2024, 04:30:30 pm »
I'm using Lazarus 3.0 (64-bit), Windows 10 (64-bit).
<snip>
Unless this applies to a newer version of Lazarus.
Yes, that behavior is from v3.99 (Lazarus trunk.) 

I normally use Lazarus v3.2 and in that version I haven't experienced that problem.

What I don't know is if it is caused by a bug or some IDE setting.  I'd like to find that out.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4541
  • I like bugs.
Re: v3.99 code completion question
« Reply #3 on: April 21, 2024, 09:12:38 am »
Yes, that behavior is from v3.99 (Lazarus trunk.) 
I normally use Lazarus v3.2 and in that version I haven't experienced that problem.
What I don't know is if it is caused by a bug or some IDE setting.  I'd like to find that out.
In a test app I put
Code: Pascal  [Select][+][-]
  1.   abc: Array
and then press Ctrl-Space to open the completion list. Then I press Space and indeed the first item in the list (ArrayStringToPPchar) is added.

I happen to have a binary of Lazarus 3.0RC2 here. I tested and it behaves exactly the same. I believe Lazarus 3.2 also behaves the same.
Are you sure your v3.99 and v3.2 work differently?

The behavior itself is a borderline between feature / bug. If you don't want any completion, press Esc to close the completion list.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

440bx

  • Hero Member
  • *****
  • Posts: 4727
Re: v3.99 code completion question
« Reply #4 on: April 21, 2024, 10:03:18 am »
Are you sure your v3.99 and v3.2 work differently?
Completely different, night and day.

This last version of trunk is the first version of Lazarus I use that wants to change my "array" to something totally unrelated (and that's not the only word that triggers it.)   

It's because the behavior is so different that I thought it was caused by some setting but, after disabling just about everything I could think of, it still insists on inserting text I did nothing to get (except type my code as I normally do.)

Lazarus v3.2 works great. 

Maybe I'll create a brand new trunk installation (instead of updating an existing trunk installation, which is what I did to get this installation.)   I don't care much to do that because, every time I do it, I have to re-establish all the settings I had in the previous installation and, I never remember all the settings I changed and to what values I set them.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Eugene Loza

  • Hero Member
  • *****
  • Posts: 729
    • My games in Pascal
Re: v3.99 code completion question
« Reply #5 on: April 21, 2024, 10:41:29 am »
Oh, only now I realized that it's the reason why I have turned the autocompletion off. For me it messes up begin and end keywords so hard that it was impossible to work...
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10546
  • Debugger - SynEdit - and more
    • wiki
Re: v3.99 code completion question
« Reply #6 on: April 21, 2024, 11:54:01 am »
I went back and check 3.3(fixes), 2.2.6 and 2.0.12

Code: Pascal  [Select][+][-]
  1. var a: array

All version suggest some longer identifier.

Even if I have "include identifiers containing prefix": "from current unit", and the word already is somewhere in the source.



array, begin, end seem to be absent, even if "include all keywords and operators" is checked. And the purpose of this, is to include them... (but then it only contains what was contributed, and I haven't seen active work on it / It's part of the new "open autocompletion always, even without dot").

440bx

  • Hero Member
  • *****
  • Posts: 4727
Re: v3.99 code completion question
« Reply #7 on: April 21, 2024, 03:26:01 pm »
in v3.2, I can type "array" and there is no popup suggesting anything and it leaves my code alone.

I can't think of what's causing v3.99 to behave the way it does.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10546
  • Debugger - SynEdit - and more
    • wiki
Re: v3.99 code completion question
« Reply #8 on: April 21, 2024, 04:29:27 pm »
in v3.2, I can type "array" and there is no popup suggesting anything and it leaves my code alone.
"there is no popup" => that is important.

Though, both 3.2 and 3.99 have the option to give you that popup.

Attached image is from 3.2.

Eugene Loza

  • Hero Member
  • *****
  • Posts: 729
    • My games in Pascal
Re: v3.99 code completion question
« Reply #9 on: April 21, 2024, 04:47:52 pm »
And I must admit that autocompletion on type is the most convenient feature why I'm still stuck with Notepad++ for languages other than Pascal. I only wish it had a basic understanding of the language :) not just picking up words from the opened document + a few basic keywords.
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

440bx

  • Hero Member
  • *****
  • Posts: 4727
Re: v3.99 code completion question
« Reply #10 on: April 21, 2024, 04:53:43 pm »
@Martin,

Thank you!!!!!  that was it!  I could have sworn I had unset that option but, obviously I didn't.  Now that it's unchecked things are working as they should :)

It's amazing the difference one little thing can make.  It was unusable with that setting checked.

Now, I can use v3.99 again and hopefully give you some feedback on the debugging features you've been working on.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10546
  • Debugger - SynEdit - and more
    • wiki
Re: v3.99 code completion question
« Reply #11 on: April 21, 2024, 05:05:36 pm »
And I must admit that autocompletion on type is the most convenient feature why I'm still stuck with Notepad++ for languages other than Pascal. I only wish it had a basic understanding of the language :) not just picking up words from the opened document + a few basic keywords.

Well, if you want to improve it in Lazarus, you should test it, and report any parts that don't work (if you can with patches, but if not still report them).
Otherwise, it is unlikely to change.

Some of the keywords are vaguely bound to context. But most are offered to broadly. (And it wont be easy to change that, but...)

Eugene Loza

  • Hero Member
  • *****
  • Posts: 729
    • My games in Pascal
Re: v3.99 code completion question
« Reply #12 on: April 21, 2024, 05:08:57 pm »
Quote
Well, if you want to improve it in Lazarus...
I wish I had enough knowledge&skill to dive into something that complex...  :'(
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10546
  • Debugger - SynEdit - and more
    • wiki
Re: v3.99 code completion question
« Reply #13 on: April 21, 2024, 05:26:41 pm »
Quote
Well, if you want to improve it in Lazarus...
I wish I had enough knowledge&skill to dive into something that complex...  :'(
You do have the knowledge that it does no offer the keyword begin, end, array? Maybe others?

Thing is, I don't use that feature, so I don't become aware of those issues. And I don't know how many other team members (if any) use that feature. Since the feature was only added as a user contributed. (So it seems no team member had missed it).

I can't promise you how soon any reported issues on it will be addressed. But non reported issues are way less likely....

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4541
  • I like bugs.
Re: v3.99 code completion question
« Reply #14 on: April 21, 2024, 08:41:25 pm »
I wish I had enough knowledge&skill to dive into something that complex...  :'(
The code base is big. I also have to study a relevant piece of code always when I implement or fix something.
Often the biggest challenge is to find the right place in code. Once it is found, it is easy (?) to analyze.
Some hints how to find a certain piece of code:

If the feature is controlled by GUI, find the resourcestring used in it and see where it is used.
For example in this case unit LazarusIDEStrConsts has
Code: Pascal  [Select][+][-]
  1.   lisAutomaticallyInvokeOnType = 'Automatically invoke on typing';
Searching lisAutomaticallyInvokeOnType reveals it is used in unit codetools_identifiercompletion_options for ICAutoInvokeOnTypeCheckBox.Caption. Then follow ICAutoInvokeOnTypeCheckBox. And so on...

Use Git commands to find the commit that implemented or changed a certain feature.
Code: [Select]
git blame ide/lazarusidestrconsts.passhows among other lines :
Code: [Select]
989ab16b3b3 (mattias        2013-07-30 14:37:53 +0000 5545)   lisNoPascalFile = 'No Pascal file';
75b7c1bd1ea (juha           2014-06-15 11:52:01 +0000 5546)   lisUnableToFindPascalUnitPasPpForLfmFile = 'Unable to find Pascal unit (.pas, .pp) for .lfm file%s"%s"';
4e1442e5ee8 (mattias        2009-07-29 10:44:03 +0000 5547)   lisLFMIsOk = 'LFM is ok';
4e1442e5ee8 (mattias        2009-07-29 10:44:03 +0000 5548)   lisClassesAndPropertiesExistValuesWereNotChecked = 'Classes and properties '
4e1442e5ee8 (mattias        2009-07-29 10:44:03 +0000 5549)     +'exist. Values were not checked.';
28f092feb1d (maxim          2015-08-08 12:06:14 +0000 5550)   lisIdCOpening = 'Opening';
f3f864d9677 (martin         2020-06-06 15:16:21 +0000 5551)   lisAutomaticallyInvokeOnType = 'Automatically invoke on typing';
f3f864d9677 (martin         2020-06-06 15:16:21 +0000 5552)   lisAutomaticallyInvokeOnTypeUseTimer = 'Use completion box delay';
f3f864d9677 (martin         2020-06-06 15:16:21 +0000 5553)   lisAutomaticallyInvokeOnTypeOnlyWordEnd = 'Only complete when at end of word';
f3f864d9677 (martin         2020-06-06 15:16:21 +0000 5554)   lisAutomaticallyInvokeOnTypeMinLength = 'Only complete if word is longer or equal';
f7cef69d2e3 (mattias        2009-08-19 15:56:18 +0000 5555)   lisAutomaticallyInvokeAfterPoint = 'Automatically invoke after point';
b5bbdbd3234 (mattias        2015-10-14 10:09:15 +0000 5556)   lisAutomaticallyUseSinglePossibleIdent = 'Automatically use single possible identifier';
The relevant line was committed by Martin in f3f864d9677.
Code: [Select]
git checkout f3f864d9677brings us there and gitk shows details of it. 5 files were modified. The commit message is :
 IDE, SourceEditor: implemented identifier-completion activates on typing. Issue #0033054 (different from patch)
The linked bug tracker issue may give further information.
Following the changes should lead further to the actual completion feature code.

For haunting regression bugs git bisect is a very useful command.

If you know a certain piece of code is involved but you don't know the code path leading to it (it is called from many places), debug the IDE using another instance of the IDE and project lazarus.lpi.

The above debug method may screw up mouse messages when dealing with GUI code. Then it is better to debug with DebugLn() calls. They are very useful and give lots of data quickly when put in strategic places.

These were generic methods that can be used for finding any code.
At least I use them often.
« Last Edit: April 21, 2024, 08:53:21 pm by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

 

TinyPortal © 2005-2018