vscode-ibmi icon indicating copy to clipboard operation
vscode-ibmi copied to clipboard

Allow Save As and breadcrumb navigation

Open sebjulliand opened this issue 1 year ago • 6 comments
trafficstars

Changes

Resolves https://github.com/codefori/vscode-ibmi/issues/2004

This PR completes the QSYS and IFS FileSystemProviders implementation. By doing so, it allows for Save As and the editor breadcrumb navigation to work for members and streamfiles.

The stat method had to return an actual result, createDirectory and readDirectory had to be implemented, writeFile had to be modified because Save As first creates an empty file then writes into it.

Save As

Streamfiles and members can now be Saved As (using ctrl+shift+s or the menu action).

For streamfiles, it works like an usual unix file system. browsing the IFS works from there. image

If the target path doesn't exist, it will be created. image

Overwriting an existing file asks for a confirmation as expected. image

For QSYS members, it works the same (navigation, creation of target path, overwriting). But since it's a QSYS path, the path must always be in the form of /LIBRARY/FILE/MEMBER.TYPE. The library and/or file will be created if needed when saving as.

Breadcrumb navigation

Clicking on the part of a path in an editor with a member or streamfile opened will allow to navigate to another location to open another member/stream. image image

How to test this PR

  • Open a streamfile or a member
  • Try navigating from the breadcrumbs
  • Try to Save As
    • As a new file in an existing directory/source physical file
    • As a new file in a non existing directory/library/source physical file
    • As an existing file (to overwrite it)

Checklist

  • [x] have tested my change
  • [x] Remove any/all console.logs I added

sebjulliand avatar May 16 '24 20:05 sebjulliand

@sebjulliand AMAZING - AND I HAVEN'T EVEN TESTED IT YET! YOU'RE MY HERO!! 😍

chrjorgensen avatar May 17 '24 06:05 chrjorgensen

@chrjorgensen I think I finally managed to fix Save As for your use case. A file name ending with . is not valid when using Save As (VSCode doesn't allow it, there is no way around this). But, if you want to save as a member with no extension, just don't put an extension in the name; QSYSFS will now handle it correctly.

I had to change a bit parserMemberPath to do so, but it's for the best (hopefully). You can give it another go whenever you want. Thanks!

sebjulliand avatar May 17 '24 21:05 sebjulliand

There are still some issue with Save as reporting the error: billede

When I as the first thing open a member for browse and choose Save as, I get the error. Open for edit does not show this error, and after open for edit, I can open for browse and use Save as... sometimes, because often it accepts the save but does not actaully save...

chrjorgensen avatar May 23 '24 06:05 chrjorgensen

@chrjorgensen give it another go. I removed the stat cache...hopefully the performance overhead won't be terrible.

sebjulliand avatar Jun 03 '24 14:06 sebjulliand

@sebjulliand What's the status here? Does it need a lil' TLC or can I review?

worksofliam avatar Jul 01 '24 16:07 worksofliam

@sebjulliand What's the status here? Does it need a lil' TLC or can I review?

@worksofliam I need to make some changes...this week of the week after 🥲

sebjulliand avatar Jul 01 '24 19:07 sebjulliand

@chrjorgensen , it's back for review, finally 😅

Works alright when member is opened for edit - when opened for browse, the error This folder cannot be used as destination. Please choose another folder. is shown.

I could get Save As to work for members/streamfiles opened in read-only mode. The only limitation is that the saved as member/file will still be opened in read-only because its URI share the same fragment as its "parent". I can't overcome this until we change the way our file systems handle the read-only flag (something I'll keep in the back of my head 😄).

There is also an issue with member names with variants - I can't even open these members, even after merging master branch into the PR branch...? Can you make it work with variants

Done! Variant characters needed to be converted to their CSSID 37 counterparts before being fed to the attr command. It works well now. Even creating a source file on the fly with variants!

Ideally the text of the new members should be set to the same as the original member - but this could be implemented in a future change.

Sadly, I tried to find a way but since we cannot know which file is being saved as by the time the target is being created and written, we can't copy the description 😑

sebjulliand avatar Sep 03 '24 20:09 sebjulliand

Thanks a lot for looking into this @julesyan ! Let's merge 😄

sebjulliand avatar Sep 25 '24 11:09 sebjulliand