Skip to content

Conversation

@richardm90
Copy link
Contributor

Fix signature help crash with colon-prefixed parameters

Issue

Fixes #459

When typing a colon (:) as the first character in a BIF parameter (e.g., changing %scan(code); to %scan(:code);), the signature help provider would crash with:

Root Cause

The Statement.getParameters() method in language/statement.ts was attempting to access newBlock[0].range without checking if newBlock was empty. When a separator (:) appeared as the first token in a parameter position, newBlock would be empty, causing the error.

Changes

  • language/statement.ts:35: Added guard condition if (newBlock.length > 0) before accessing newBlock[0].range
  • tests/suite/basics.test.ts:2071-2135: Added comprehensive unit test statementGetParametersEmptyBlock that directly tests the fix

Test Coverage

The new test validates:

  1. Single separator as first token: [':'] (the bug scenario)
  2. Multiple consecutive separators: [':', ':']
  3. Normal case with content before separator: ['code', ':', 'str']

Checklist

  • have tested my change
  • updated relevant documentation
  • Remove any/all console.logs I added
  • eslint is not complaining
  • have added myself to the contributors' list in the README
  • for feature PRs: PR only includes one feature enhancement.

Copy link
Member

@SanjulaGanepola SanjulaGanepola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@richardm90 Thanks for looking into this and great test cases. After manually testing it, I noticed there was still an issue in the signature help:

With the current changes, the first parameter is highlighted even when the cursor is on the second parameter:

image

With the suggested changes below, this is fixed:

image

@richardm90
Copy link
Contributor Author

@SanjulaGanepola , good catch, I'll take a look.

@richardm90
Copy link
Contributor Author

@SanjulaGanepola, all of those changes were good and I've applied and tested them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RPGLE fails when typing a procedure in a specific way

2 participants