codefori / vscode-ibmi

🌍 IBM i development extension for VS Code
https://codefori.github.io/docs/#/
MIT License
282 stars 92 forks source link

Support right-click edit action when read-only mode is enabled #2097

Open SanjulaGanepola opened 4 months ago

SanjulaGanepola commented 4 months ago

Is your feature request related to a problem? Please describe.

When the Read only mode option is enabled, I noticed that members and IFS files are opened in read only mode as expected. However, when using the right-click Open -> Edit action, it still opens it in read only mode. This seems unexpected as the inverse scenario works as expected where this option is disabled and selecting Open -> Browse makes the file read only.

image

Describe the solution you'd like

I wasn't sure if this was a bug or the expected behavior since the description of the option does say "always be opened in read-only mode" which does match what it does. However, should the wording be changed to "When enabled, source members and IFS files will be opened in read-only mode by default" and then support the right-click Edit action. This is so that in most case I will be browsing, but I can still occasionally edit files without having to disable the entire setting.

I can add this change if it is acceptable.

chrjorgensen commented 4 months ago

@SanjulaGanepola The Read only mode option came after a user request for a way to prohibit ANY editing via a filter, because the user had production source that may never be touched. So I think it is working as designed.

However, the Open -> Edit action should probably not be active and available when the filter is protected, i.e. read only. This way the user will know editing is not available through this filter.

There is also an extension setting Default Open Mode to set which option - browse or edit - is the default action when a file is clicked. This could be used in your case to browse in most cases but edit occasionally. I have it set to Browse and have to click Open -> Edit to open a file for edit.

Only thing missing is a quick way to make an opened file change from browse mode to edit mode (if the filter allows editing) - instead of having to close the file, find it in the Object Browser and right-click, select Open and then Edit. A bit cumbersome as is now....

SJLennon commented 3 months ago

FWIW: As far as I can see there are four "read only" type controls, which I didn't realize until reading this issue.

1) In a filter definition you can specify Protected and source cannot be modified and cannot be overridden with Open -> Edit/Browse.
2) Protected paths sets "read only" for an entire library or IFS path and cannot be overridden with Open -> Edit/Browse. 3) Read only mode is a connection level setting and cannot be overridden with Open -> Edit/Browse 4) Default open mode applies to all connections, but you can override it with Open -> Edit/Browse

I this is correct, I'll try to make this clear in the documentation.

SJLennon commented 2 weeks ago

I created docs pull request 40 to reflect the above.