Forum > Editor

[SOLVED] "Ctrl+Space" causes an error with a cursor outside of code

<< < (2/2)

Martin_fr:
If it is 100% reproducible, then it calls for a bug report.

If the sources are private, then maybe once someone picks up the bug, that developer can contact you and receive them in confidence (you would need to keep a snapshot, of the current version).

About the menu entry. My bad, it's only added with the package cody installed (afaik, it's cody).

Btw: Cody, most useful => "identifier dictionary"
(may take a couple of sessions, before it has enough data, but then can find identifiers in units, even if they are not used by the project)

furious programming:
Damn, I solved this problem. I wanted to write about it right away, but the forum was not reachable (it happens quite often), so I went for a walk.

I deleted only the Game_InputMappingAction file from the project files tree, because I was redirected to it when I tried to use the codetool in the Game_InputMapping unit. And even though Game_InputMappingAction was no longer part of the project, codetool still redirected me to it — load it to the editor window and show the above mentioned error.

So I deleted the Game_InputMappingAction file from the disk (I actually moved it to a different directory) so the IDE could not find it. In the code editor, I moved to the Game_InputMapping unit and pressed Ctrl+Space in a random place — the IDE did nothing, no error appeared, and the window with the list of identifiers appeared (caused by a shortcut). After re-adding the Game_InputMappingAction unit to the project (using the Project Inspector window), the codetool started working properly and this problem no longer occurs.


Apparently the codetool did have corrupted data. However, I still don't know where this problem came from and what caused it, so even if I would like to report a bug, I don't have any information on how to cause it — only the error message remains.

Problem solved, and in case someone also encounters one, try it in the same way:

* remove the unit to which the IDE redirects from the project and shows the error cursor pos outside of code in it, using the Project Inspector window,
* delete this file from the disk, so that the IDE no longer has any access to it (just temporarily move this file to another directory),
* open in the IDE the unit in which codetool did not work, place the cursor anywhere and press Ctrl+Space — no error should pop up,
* restore a deleted file to its previous location (or create new),
* open the Project Inspector window and add the previously deleted file to the project,
* try to use codetool on both units — it shouldn't be any problem anymore.

BeniBela:
Lazarus would be better if it  would just ignore the error and show a list anyways when there is an error. It could show the ctrl+w list as fallback if it really cannot get anything for the normal list

I usually use the newest FPC syntax features (generics, typehelpers, etc.) before Lazarus knows them, so I can almost never use Codetools. Eventually the error is fixed, but by then I am using a new syntax, and get another error from it

PascalDragon:

--- Quote from: BeniBela on June 16, 2022, 09:50:27 pm ---Lazarus would be better if it  would just ignore the error and show a list anyways when there is an error. It could show the ctrl+w list as fallback if it really cannot get anything for the normal list
--- End quote ---

It should at least show the error in the message box as it does now, cause otherwise users might think that everything is alright and then complain that they don't get fancy code completion.

Martin_fr:

--- Quote from: BeniBela on June 16, 2022, 09:50:27 pm ---Lazarus would be better if it  would just ignore the error and show a list anyways when there is an error. It could show the ctrl+w list as fallback if it really cannot get anything for the normal list

--- End quote ---

Well, then it has been better for quite some time...

Menu:  Tools > Options
Use the search box, and look for "error", you will find
   Codetools > Identifier Completion > "Jump to error"

Which you can switch off.

According to my tests:
- get the error in the message box
- get the word completion (I don't think, there would ever be a "partial" codetool list, but I did never check for it)

It may however be, that getting the word completion depends on the kind of error encountered... It works for me.

-- EDIT

No idea why the default is as it is. But probably:
- original behaviour, from the days of yore
- people might want to know, if they have actual errors in their source. And that is not just by accidentally spotting it in the messages window.

The latter of course depends on what the most common cause for errors is. And that differs for each individual. If you are new to pascal, you may have lot of errors of your own.

IMHO, the best would be, if instead of jumping, the drop down had an entry "Syntax error ... found at ..." or similar.
That entry could be non-selectable. It would just be a more visual indicator. You could then still click the error in the message-view. Or it could be linked to a hot-key. Or even offer an automated quick fix....

But in the absence of this....

Navigation

[0] Message Index

[*] Previous page

Go to full version