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

feat: allow dragging sas content into editor #510

Merged
merged 13 commits into from
Oct 17, 2023
Merged

Conversation

scottdover
Copy link
Contributor

Summary
This adds the ability to drag sas content into sas programs. See #329 for more details

Testing

  • Tested dragging a folder into a SAS program (should not provide any code)
  • Tested dragging a file into a SAS program from my folder
  • Tested dragging a file into a SAS program from my favorites
  • Tested dragging files into a SAS program from nested folder paths
  • Tested dragging two files from the same folder into a SAS program

@Zhirong2022
Copy link
Collaborator

It failed to run the generated FILENAME statement if the fileref name having more than 8 bytes. And fileref name must conform to the rules for SAS names.
Error details:
ERROR: Invalid logical name.
ERROR: Error in the FILENAME statement.

@scottdover
Copy link
Contributor Author

@Zhirong2022 Can you provide an example of an invalid file name? Also, do you know where the "rules for SAS names" might be (like, is it documented somewhere)?

@scottdover
Copy link
Contributor Author

It failed to run the generated FILENAME statement if the fileref name having more than 8 bytes. And fileref name must conform to the rules for SAS names. Error details: ERROR: Invalid logical name. ERROR: Error in the FILENAME statement.

I scrapped the file name generation part of this in favor of using a tab stop to fill in the fileref. Now, when a user drags a file into an editor, we'll automatically select/place a cursor at fileref where they can rename as needed.

Screenshot 2023-09-26 at 2 40 56 PM

@Zhirong2022
Copy link
Collaborator

@Zhirong2022 Can you provide an example of an invalid file name? Also, do you know where the "rules for SAS names" might be (like, is it documented somewhere)?
@scottdover Please visit the SAS help to find the detail. And "rules for SAS names" means
names can be 1 to 8 characters long, must begin with a letter (A-Z, either uppercase or lowercase) or an underscore (_), and can continue with any combination of numbers, letters, or underscores.
image

@Zhirong2022
Copy link
Collaborator

Quotation marks mismatch if the file name contains them and it will fail to run the code as well.
image

@scottdover
Copy link
Contributor Author

Quotation marks mismatch if the file name contains them and it will fail to run the code as well. image

This has been addressed in 214d11e.

That said, a sas program like the following will still not run:

filename fileref2 filesrvc folderpath='/Users/anon/My Folder' filename="test-'file'.csv";
data _null_; infile fileref2; input; put _infile_; run

I attempted to find a workable solution by using the file step in studio to produce code. The code it produced is similar to the code above, and both failed to run with this error:

ERROR: Physical file does not exist, test-'file'.csv.

All this is to say, I don't think there's anything I can do in this PR to address, but I just wanted to bring it up.

@Zhirong2022
Copy link
Collaborator

Quotation marks mismatch if the file name contains them and it will fail to run the code as well. image

This has been addressed in 214d11e.

That said, a sas program like the following will still not run:

filename fileref2 filesrvc folderpath='/Users/anon/My Folder' filename="test-'file'.csv";
data _null_; infile fileref2; input; put _infile_; run

I attempted to find a workable solution by using the file step in studio to produce code. The code it produced is similar to the code above, and both failed to run with this error:

ERROR: Physical file does not exist, test-'file'.csv.

All this is to say, I don't think there's anything I can do in this PR to address, but I just wanted to bring it up.

Well, it might run into such kind of scenarios if the file/folder name contains quotation marks. Ideally, it would be perfect to have a statement without any errors. The user can fix it manually. Normally, we do not suggest to new a file/folder having special characters otherwise it will cause some troubles unexpectedly.

@scnwwu scnwwu added this to the 1.5.0 milestone Oct 7, 2023
@Zhirong2022
Copy link
Collaborator

The filepath is not changed accordingly in filename statement in certain case, please follow the steps below to reproduce

1.Create a new file folder named like 'NewFolderTest' under My Folder, new a .sas file named like 'NewFileTest.sas' under 'NewFileFolderTest'.
2.Delete file folder 'NewFileFolderTest'
3.Drag and drop NewFileTest.sas into editor to create filename statement, it works as expected
4.Restore the file folder 'NewFileFolderTest'
5.Drag and drop NewFileTest.sas into editor, the folderpath still pointed to Recycle Bin

@scottdover
Copy link
Contributor Author

The filepath is not changed accordingly in filename statement in certain case, please follow the steps below to reproduce

1.Create a new file folder named like 'NewFolderTest' under My Folder, new a .sas file named like 'NewFileTest.sas' under 'NewFileFolderTest'. 2.Delete file folder 'NewFileFolderTest' 3.Drag and drop NewFileTest.sas into editor to create filename statement, it works as expected 4.Restore the file folder 'NewFileFolderTest' 5.Drag and drop NewFileTest.sas into editor, the folderpath still pointed to Recycle Bin

This was due to a little cache that I put together that wasn't really saving us that much. I've since removed the cache and things should be working as expected now.

@Zhirong2022
Copy link
Collaborator

The feature works as expected.

@Zhirong2022 Zhirong2022 added testing-complete Complete the pull requests testing and removed testing Test the pull requests labels Oct 13, 2023
@scottdover scottdover merged commit 4c172f6 into main Oct 17, 2023
1 check passed
@scottdover scottdover deleted the feat/sas-content-link branch October 17, 2023 18:00
@Zhirong2022 Zhirong2022 added ready for release Code pushed, but not released in VS code marketplace yet and removed testing-complete Complete the pull requests testing labels Oct 26, 2023
@tianliang657 tianliang657 added the automation Issue has been covered by automation test label Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automation Issue has been covered by automation test ready for release Code pushed, but not released in VS code marketplace yet
Projects
None yet
5 participants