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

Re-factor can only find instances of function in opened files #519

Closed
gowerc opened this issue Feb 2, 2022 · 5 comments
Closed

Re-factor can only find instances of function in opened files #519

gowerc opened this issue Feb 2, 2022 · 5 comments
Labels

Comments

@gowerc
Copy link

gowerc commented Feb 2, 2022

This might be a limitation of vscode rather than this extension but I thought I'd raise it anyway just encase (feel free to close if its a vscode issue)

Describe the bug
Using vscodes refactor features in an R package seems to only detect occurances in files that have been opened at least once during the session. If a file has not been opened then the occurance is not detected and it will be excluded from the renaming.

image

In the above screenshot instances of the "draws" function are only shown from files that I have previously opened. If I haven't opened the file then the occourance of "draws" is not shown

To Reproduce
Steps to reproduce the behavior:

  1. Create a function
  2. Use it in several different files
  3. Reset your vscode instance
  4. only open 1 file using the function
  5. right click -> "go to references"
  6. only the instances in files that have been opened at least once will be shown

Do you want to fix by self? (We hope your help!)

No

Expected behavior
that all instances would be shown even if the file hasn't yet been opened

Environment (please complete the following information):

  • OS: macOS
  • VSCode Version: 1.63.2
  • R Version: 4.1.2
  • vscode-R version: v2.3.6
@gowerc gowerc added the bug label Feb 2, 2022
@gowerc
Copy link
Author

gowerc commented Feb 2, 2022

Ok this is weird it seems to work on some functions as exected but not in others, I'm not sure yet what causes some to fail and not others....

For example on the draws function as show in the above screenshot it doesn't work at all in a fresh vscode session but then for another function validate it shows everything as expected ... :S

Edit: Repo in question if you wanted to test for yourselves - https://github.com/insightsengineering/rbmi

2022-02-02 14 48 13

@renkun-ken renkun-ken transferred this issue from REditorSupport/vscode-R Feb 2, 2022
@renkun-ken
Copy link
Member

It is a known behavior of the language server, i.e. the language server provides language features such as find references, rename, etc. within the language server workspace. More specifically,

  • If the editor workspace contains an R package, then the language server workspace contains all R files in R.
  • Otherwise, the language server workspace only contains open files in the editor.

Related: #386

@gowerc
Copy link
Author

gowerc commented Feb 2, 2022

@renkun-ken,

If i'm understanding you correctly, then the behaviour I'm experiancing is a bug because both of the files shown above are in the same project & folder which is also an R package. Based on your description I wouldn't have expected the references for "validate" to work and those for "draws" not to work as they are both within the same R package.

For reference the draws function is in the R/draws.R file and the validate function is in the R/validate.R file yet for some reasons validate works and draws doesn't ... ?

Edit: I'm assuming I need to re-raise this as a bug on the languageserver repo then ?

@renkun-ken
Copy link
Member

renkun-ken commented Feb 3, 2022

From your screencasts, it seems that you are trying to find-reference or rename a symbol defined in R/*.R but used in misc/*.R. The language server workspace of an R package only contains R files in R folder, but not others initially. As you open files in other folders, the language server workspace also contains those open files, so that find-reference and rename also cover those files.

@gowerc
Copy link
Author

gowerc commented Feb 3, 2022

ah apologies well spotted I will close this then and put any more comments in the linked issue. Thank you for looking at this !

@gowerc gowerc closed this as completed Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants