Turning off begin ... end autocompletion. lazarus / 9-Editor ---------------------------------------------------------------------- lazer · 2022-10-23 08:14 Hi, Is it possible to stop lazarus attempting to auto-complete begin ... end blocks for me. This is very annoying since it is always trying to double guess what it thinks I need to do and usually gets it wrong. having spurious or duplicate end statements totally messes up the code for the compiler and everything stops making sense to it. This means loads of errors in following code and it can be time consuming to  work out where exactly  the extra code go inserted behind my back. This costs me WAY more time that it takes me to type "end;" on my own. It needs to get out of my face and let me type. If someone can explain how to turn off this "feature", it will be thorn out of my side. TIA. ---------------------------------------------------------------------- wp · 2022-10-23 08:54 That's one of the few things that I change after installing a new IDE: Right-click on editor > "Options" (or "Tools" > "Options" > "Editor"), then "Completion and Hints": uncheck "Add close statements for Pascal blocks". ---------------------------------------------------------------------- paweld · 2022-10-23 08:59 But you can enable an outline pascal code blocks, then the blocks are visible and you can easily find the begin and end of block: https://wi ki.lazarus.freepascal.org/New_IDE_features_since#Outline_for_Pascal_So urces ---------------------------------------------------------------------- lazer · 2022-10-23 09:51 Quote from: wp on October 23, 2022, 10:54:18 amThat's one of the few things that I change after installing a new IDE: Right-click on editor > "Options" (or "Tools" > "Options" > "Editor"), then "Completion and Hints": uncheck "Add close statements for Pascal blocks". THANKS. You just saved by monitor from an early death ! That still took some finding, it was tucked away under mouse for some reason. If it is realated to mouse movement as well as typing that may explain why it is so erratic and difficult to know whether it's doing it or not. This is definitely the most irritating and destructive default "feature" of the IDE. It has got my code into a state where it won't compile and a double- click on a form ( to get to the onclick method ) fails and  throws an exception.  Do this a few times and Lazarus locks up totally and I need to OS to kill it.  What a mess. 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 Hint: (lazarus) [TMainIDE.DoBuildProject] compiler time in s: 0.756000098772347Error: (lazarus) [TMainIDE.DoBuildProject] Compile failedInfo: (lazarus) [TMainIDE.DoInitProjectRun] DoBuildProject failed### TCodeToolManager.HandleException: [20170421195037] "unexpected keyword "procedure" in begin..end found. start at (402,1)" at Line=448 Col=1 in "main.pas"Error: (lazarus) TMainIDE.PropHookCreateMethod failed adding method "helpHelpClick" to sourceTApplication.HandleException: ExceptionUnable to create new method. Please fix the error shown in the message window which is normally below the source editor.  Stack trace:  $00000000004E192A  PropHookCreateMethod,  line 13209 of main.pp  $000000000097CE1F  CreateMethod,  line 6394 of propedits.pp  $0000000000978683  Edit,  line 4895 of propedits.pp  $00000000009A4FBC  Edit,  line 844 of componenteditors.pas  $0000000000A72218  AddOnClick,  line 660 of ../designer/menueditor.pp  $0000000000A78BD0  DblClick,  line 2182 of ../designer/menueditor.pp  $00000000005AA823  WMLButtonDBLCLK,  line 2592 of include/control.inc  $0000000000433801  $000000000059B8DD  WndProc,  line 5427 of include/wincontrol.inc  $000000000079F60F  DeliverMessage,  line 112 of lclmessageglue.pas  $000000000066CD95  DeliverMessage,  line 3776 of gtk2proc.inc  $000000000067CA56  DeliverMouseDownMessage,  line 2101 of gtk2callback.inc  $000000000067BFD5  gtkMouseBtnPress,  line 1839 of gtk2callback.inc  $00007F762FD56669TWinControl.CreateWnd ShadowMenu:TShadowMenu Parent=nil ERROR WndParent=0TApplication.HandleException: EInvalidOperationControl "ShadowMenu" has no parent window.  Stack trace:  $00000000005A0791  CreateWnd,  line 7537 of include/wincontrol.inc  $00000000004829F4  CreateWnd,  line 31 of include/scrollingwincontrol.inc  $000000000059FF40  CreateHandle,  line 7453 of include/wincontrol.inc  $00000000005A17E9  HandleNeeded,  line 7906 of include/wincontrol.inc  $00000000005A17C0  HandleNeeded,  line 7900 of include/wincontrol.inc  $00000000005A17C0  HandleNeeded,  line 7900 of include/wincontrol.inc  $000000000059E059  GetHandle,  line 6515 of include/wincontrol.inc  $000000000067CA78  DeliverMouseDownMessage,  line 2105 of gtk2callback.inc  $000000000067BFD5  gtkMouseBtnPress,  line 1839 of gtk2callback.inc  $00007F762FD56669TApplication.HandleException: EAccessViolationAccess violation  Stack trace:  $00007F76301725D4  Thanks for the help , you saved my day ! ---------------------------------------------------------------------- Martin_fr · 2022-10-23 12:56 Quote from: lazer on October 23, 2022, 11:51:24 amIt has got my code into a state where it won't compile and a double-click on a form ( to get to the onclick method ) fails and  throws an exception.  Do this a few times and Lazarus locks up totally and I need to OS to kill it.  You really seem to have a spell of bad luck.... Or, well, you just dug out some code that is great for testing, because it has all the odds and bits that other people don't use and therefore triggers a lot of code that hasn't been tested in too long a time.... 1) Auto-add "end" should of course not "break the code". I know it be a lot to ask you to track it down (since you had a lot of tracking already). But if by chance you have code, were it goes wrong => please create a bug report (I don't use it myself either. "end" does hardly take any time to type) 2) Adding "OnClick" (adding methods via designer/OI) => That of course requires correct code. If "end" are incorrectly placed the IDE can't tell where to place the new code. So once the first point stroke.... The first of the 2 exceptions, relates to this, and is expected, and should be handled. (and also should have given you an error in the messages window, that told you were it got stuck. That said, the internal "codetool" parser, sometimes fails on correct code => here again, if possible bug reports. (If it is generic related, there already are some reports) (almost) needless to say, I can get the "Unable to create new method", but I don't get the 2nd trace => though I am on Windows, and this may only happen on Linux) 3) The hanging IDE => from the trace, I figure this is "menu editor" related. Don't know more. (And not my turf) Though it could be a consequence of the first trace, if for some reason that was not handled as expected. In that context: Do you use Anchor-docking? (If you do, you would know, for you would have had to install the package (and maybe related packages) through the "install package" menu.) There are people who swear it is all good. I only test it very occasionally (and never yet with the form designer). And I am not that convinced. IMHO it's chicken and egg, it's not installed by default, so it's used by probably fewer people, so it has less testing. Also there are "sparta*" packages related to docking => consider them broken. ---------------------------------------------------------------------- lazer · 2022-10-23 13:20 I really don't have any more time to pin down this kind of thing.  I turned the damned thing off that's good enough for me. I meantioned the crash because it's pretty messy and should be known about. A lot of the trouble is , if it adds an extra end , it screws the parser completely. Loads of stuff goes out of scope and it throws lots of correctly but eventually spurious syntax errors. If you are the bottom of the window it can add end where it's out of sight. Sometimes it does addone , sometimes not. I've never understood the logic which makes it even more of a PITA. Auto-complete is supposed to be "cool" for people who cannot type without looking for every key on the keyboard. If you can it gets in the way. The same is true of F3 , it's forever stuffing things in there I don't want and then the search fails because it is searching for what it "thinks" I want to look for instead of WHAT I ACTUALLY ENTERED. The crash seems to be that once it fails to compile because of broken begin... end blocks it triggers bugs in auto creating methods, renaming variables in the object inspector. For example a double click on the main form should send the editor to FormCreate() event. This can fail with an exception message. It seems these are not correctly trapped and after a few occurences it hangs Lazarus. ---------------------------------------------------------------------- Martin_fr · 2022-10-23 14:18 Quote from: lazer on October 23, 2022, 03:20:32 pmI really don't have any more time to pin down this kind of thing.  I turned the damned thing off that's good enough for me. Fully understood. QuoteAuto-complete is supposed to be "cool" for people who cannot type without looking for every key on the keyboard. If you can it gets in the way. The same is true of F3 , it's forever stuffing things in there I don't want and then the search fails because it is searching for what it "thinks" I want to look for instead of WHAT I ACTUALLY ENTERED. You can control both under Tools > Options (And yes, the option dialog is massive...., and not easy to comprehend) Auto Completion and related (e.g. hints): - Editor > Completion and Hints (Delay for completion box) - Codetools > Identifier Completion (Especially "Opening") "F3" - What goes into the search text by default - Editor > General > Miscellaneous: "Find text at cursor" Disable and the "search" will open with empty text Enable, and it uses "word at cursor" or "current selection" (if single line selection) ---------------------------------------------------------------------- lazer · 2022-10-23 15:45 many thanks. At least it's configurable. ---------------------------------------------------------------------- lazer · 2022-10-23 18:38 Supplementary: I am still ploughing through a bunch of trivial syntax stuff so I don't have a clean compilation yet. I just doubleclicked on a TButton to get to its onclick handler and it threw an error again. After dismissing the error box I notes an entry in msg window with yellow background: 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 "Codetools, Errors: 1" ---------------------------------------------------------------------- dseligo · 2022-10-23 18:43 Quote from: Martin_fr on October 23, 2022, 02:56:38 pm1) Auto-add "end" should of course not "break the code". Maybe it's not actually breaking the code. Sometimes I experience adding 'end' after the visible code, as @lazer described. Then I type *another* 'end' and only then the code is broken. Usually is not hard to correct this (and if I have problems inserting methods because of this I delete additional 'end' first and maybe because of that haven't experience Lazarus' exception). ---------------------------------------------------------------------- lazer · 2022-10-23 19:02 It's OK ( but annoying ) if you notice. But if you don't and carry on making changes, by the time you get to hit F9 then extra little "end" could be anywhere in your changes. This leads to the kind of crap you get in python because you did an incorrect indentation. A trivial error completely throws the syntax and half the file becomes garbage to the parser. Sadly it's rarely as simpy as : the line just above the first error message. Quote and maybe because of that haven't experience Lazarus' exception).No, read my last , this is not restricted to chaos of end insertion. ---------------------------------------------------------------------- lazer · 2022-10-24 21:31 Quote"F3" - What goes into the search text by default - Editor > General > Miscellaneous: "Find text at cursor" Disable and the "search" will open with empty text Enable, and it uses "word at cursor" or "current selection" (if single line selection) So there is not option to turn of the annoying auto-completion. Text under cursor or selected text makes sense. It's when I open the dialogue, type "init" and hit find, only to discover that it sniffed out something beginning with "init" , auto- filled and used it, and I can't work out why the hell it can't find any matches for what I typed. After going round in circles I note it is not searching for what told it to search for but something else it thought was a better idea. ---------------------------------------------------------------------- wp · 2022-10-24 21:36 Quote from: lazer on October 24, 2022, 11:31:43 pmQuote"F3" - What goes into the search text by default - Editor > General > Miscellaneous: "Find text at cursor" Disable and the "search" will open with empty text Enable, and it uses "word at cursor" or "current selection" (if single line selection) So there is not option to turn of the annoying auto-completion. Text under cursor or selected text makes sense. It's when I open the dialogue, type "init" and hit find, only to discover that it sniffed out something beginning with "init" , auto- filled and used it, and I can't work out why the hell it can't find any matches for what I typed. After going round in circles I note it is not searching for what told it to search for but something else it thought was a better idea. Check "Whole words only" in the Find dialog? ---------------------------------------------------------------------- Martin_fr · 2022-10-24 21:51 Quote from: lazer on October 24, 2022, 11:31:43 pmSo there is not option to turn of the annoying auto-completion. Text under cursor or selected text makes sense. Oh that.... You are on Lazarus 2.3. Did you see the button just right of the "find" edit field? (Something blue and a text-cursor) It has a hint "Auto completion: on/off".... Only exists in the normal find dialog. The "find in files" does not (yet?) have it. I guess it got overlooked. (Feel free to add a feature request on the bug tracker) ---------------------------------------------------------------------- lazer · 2022-10-24 22:01 QuoteDid you see the button just right of the "find" edit field? (Something blue and a text-cursor) Ah, it's so discrete I never even noticed. by it's size and dimensions it does not even look like a button. That is perfect, thanks for pointing it out. ---------------------------------------------------------------------- lazer · 2022-10-25 13:09 Hmm, not so perfect, finally. Turning of auto stops it picking up word under cursor or selected text.  It is NOT just turning off auto-completion. ---------------------------------------------------------------------- Martin_fr · 2022-10-25 13:14 Quote from: lazer on October 25, 2022, 03:09:27 pmHmm, not so perfect, finally. Turning of auto stops it picking up word under cursor or selected text.  It is NOT just turning off auto-completion. Not for me... Have you changed that in the global IDE options? Tools > Options > Editor > Miscellaneous ? "Find text at cursor" ?