Skip to content

Commit 81eae69

Browse files
committed
Hide Access violation in CodeToolBoss.GatherIdentifiers
1 parent c233070 commit 81eae69

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

server/utextdocument.pas

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Pascal Language Server
22
// Copyright 2020 Arjan Adriaanse
33
// 2021 Philip Zander
4+
// 2025-2026 Michalis Kamburelis
45

56
// This file is part of Pascal Language Server.
67

@@ -241,9 +242,35 @@ procedure GetCompletionRecords(
241242
CodeToolBoss.IdentComplIncludeKeywords := IncludeKeywords;
242243

243244
if not CodeToolBoss.GatherIdentifiers(Code, X, Y) then
245+
begin
246+
{ Unfortunately I have cases when this happens, when trying to complete
247+
"finally SavedFontSize ..." in x3dnodes_standard_text.inc .
248+
With Lazarus from main -- not stable.
249+
250+
Propagating this problem as ERpcError, and then user showMessage,
251+
isn't good for users trying to edit Pascal in VS Code,
252+
as showing popup "Access Violation"
253+
is confusing and disruptive when editing code (user probably
254+
doesn't want to jump to debug pasls + CodeTools).
255+
256+
So we log + hide it for now.
257+
258+
(For other errors, we raise ERpcError and they will result in showMesssage
259+
to user, this is good and may be helpful.)
260+
261+
TODO: We should offer some way to reproduce this error,
262+
and submit it as CodeTools error. }
263+
264+
if Pos('EAccessViolation: Access violation', CodeToolBoss.ErrorMessage) <> 0 then
265+
begin
266+
DebugLog('Access violation in CodeToolBoss.GatherIdentifiers. Full exception message: %s', [CodeToolBoss.ErrorMessage]);
267+
Exit;
268+
end;
269+
244270
raise ERpcError.Create(
245271
jsrpcRequestFailed,
246272
PositionForErrorPrefix(CodeToolBoss) + CodeToolBoss.ErrorMessage);
273+
end;
247274

248275
Count := CodeToolBoss.IdentifierList.GetFilteredCount;
249276

0 commit comments

Comments
 (0)