Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CompletionItemProvider locating currentprocedure in wrong source #323

Closed
EVLSDE opened this issue Sep 11, 2024 · 1 comment
Closed

CompletionItemProvider locating currentprocedure in wrong source #323

EVLSDE opened this issue Sep 11, 2024 · 1 comment

Comments

@EVLSDE
Copy link

EVLSDE commented Sep 11, 2024

Describe the bug
If you use copybooks with procedure prototypes inside you'll find vs code intellisense behaving strange: the list of suggestions doesn't match with your source at all.

To Reproduce
Define a copybook with a procedure prototype definition on a specific range of code lines, e.g. from line no. 10 to 12:

**free








dcl-pr SomeProcedure;
  SomeParameter char(1);
end-pr;

Use a /copy statement to include the copybook and place a procedure inside, where the procedure body covers the same line number:

**free
  
/copy 'QCPYLESRC/somecopybook.rpgle'

dcl-proc ExportedProcedure export;
  dcl-pi *n;
    ExportParameter1 char(1);
    ExportParameter2 char(1);
  end-pi;

  
end-proc;

Now if you start typing on said lines (e.g. 10-12) in your rpg source, you won't be able to find local definitions (e.g. "ExportParameter1"), but will find parameter definitions from your copybook procedure prototype instead (e.g. "SomeParameter") - as if you were typing on the same line but in the copybook source.
If you instead start typing on another line where there's no definition (e.g. 14), you'll find the suggestions are correct.

Expected behavior
I'd expect to find the same local definitions as suggestions on every line of code in a procedure.

Screenshots
Screenshot 2024-09-11 085536
Screenshot 2024-09-11 085554
Screenshot 2024-09-11 085604
Screenshot 2024-09-11 085612

Environment

  • Extension version v0.26.8
  • IBM i OS version 7.4

Additional context
I found out that in completionItem.ts, currentProcedure is only found by comparing line numbers of definitions, but file path isn't being compared.
After I added the following code inside find() on line 34, the suggestions worked again for me:
&& currentPath === proc.position.path

I'm not sure if there's a reason why this check is missing but maybe you can consider this for a future fix.

EVLSDE pushed a commit to EVLSDE/vscode-rpgle that referenced this issue Sep 11, 2024
worksofliam added a commit that referenced this issue Sep 12, 2024
#323 check file path in completionitem.ts for currentprocedure discovery
@worksofliam
Copy link
Contributor

worksofliam commented Sep 12, 2024

Related PR release in 0.26.9.

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

No branches or pull requests

2 participants