Open chrjorgensen opened 2 days ago
but it would be better to simply call the
code-for-ibmi.openWithDefaultMode
command
That was exactly my first attempt... but then the readonly
attribute from the result view would be ignored, and we probably would like to propagate the value when the server or directory being searched is protected (would require further changes...), so I opted for this intermediate solution.
WDYT?
Hmmm...code-for-ibmi.openWithDefaultMode
calls code-for-ibmi.openEditable
with the default open mode.
code-for-ibmi.openEditable
also checks if the path is protected, or even writable, etc.
Actually, just swapping code-for-ibmi.openEditable
with code-for-ibmi.openWithDefaultMode
and keeping both arguments should do the trick. That will open using the default mode BUT honor the readonly flag in priority if it is true
.
Actually, just swapping
code-for-ibmi.openEditable
withcode-for-ibmi.openWithDefaultMode
and keeping both arguments should do the trick. That will open using the default mode BUT honor the readonly flag in priority if it istrue
.
But that didn't work for me... openWithDefaultMode
wouldn't call the GlobalConfiguration.get
function, even though overrideMode
was undefined
...?!
I can give it another shot...?
I think I understand: it will check the configuration if there is no overrideMode
.
https://github.com/codefori/vscode-ibmi/blob/ab4d38c4cc20e7139726850d17edd465dd48013c/src/instantiate.ts#L676
So I think the correct way to call the command from the search view would be:
this.command = {
command: `code-for-ibmi.openWithDefaultMode`,
title: `Open`,
arguments: [this._path, this._readonly ? 'browse' as DefaultOpenMode : undefined]
};
Forcing browse
only when the view is in read-only mode will leave it up to the command to decide how to open the editor otherwise.
@sebjulliand Seems to work now - for find results only!
Search results have the additional option of range, using type OpenEditableOptions
, which is not supported by openWithDefaultMode
... 😢
This is a case for our TypeScript guru! 🙏
Changes
This PR will add a
readonly
value to IFS search and find results, to honor the default open mode set in the configurations. When default open mode isbrowse
, clicking on a search/find result will open the file in readonly mode.How to test this PR
Examples:
browse
in the extension configurationedit
in the extension configurationChecklist