|
1 | 1 | // Pascal Language Server |
2 | 2 | // Copyright 2020 Arjan Adriaanse |
3 | 3 | // 2021 Philip Zander |
| 4 | +// 2025-2026 Michalis Kamburelis |
4 | 5 |
|
5 | 6 | // This file is part of Pascal Language Server. |
6 | 7 |
|
@@ -241,9 +242,35 @@ procedure GetCompletionRecords( |
241 | 242 | CodeToolBoss.IdentComplIncludeKeywords := IncludeKeywords; |
242 | 243 |
|
243 | 244 | 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 | + |
244 | 270 | raise ERpcError.Create( |
245 | 271 | jsrpcRequestFailed, |
246 | 272 | PositionForErrorPrefix(CodeToolBoss) + CodeToolBoss.ErrorMessage); |
| 273 | + end; |
247 | 274 |
|
248 | 275 | Count := CodeToolBoss.IdentifierList.GetFilteredCount; |
249 | 276 |
|
|
0 commit comments