Fix initial setting of LCB editor pref#1869
Fix initial setting of LCB editor pref#1869montegoulding merged 5 commits intolivecode:develop-8.2from
Conversation
The `revIDEDeveloperExtensionEditScript` handler will open an LCB file in the default editor. It uses `the result` to catch failures to open with a default editor and set a pref. The problem is that after evaluating the next put (tEditor), the original value is lost. This means that if the pref has not already been set, then the file won't get opened. This change implements a new variable `tResult` to carry forward the result though the function.
| end if | ||
|
|
||
| if the result is "no association" or the result is "request failed" then | ||
| if tResult is "no association" or the result is "request failed" then |
There was a problem hiding this comment.
There's a second the result here that should be replaced
|
@bwmilby thanks for this! |
Corrected remaining `the result` to `tResult`
|
@livecodeali Glad to help. Not sure how much help this will need merging into 9 since this code was factored out to a new function call. |
|
|
||
| if the result is not empty then | ||
| if tResult is not empty then | ||
| __revIDEDeveloperExtensionSendError "Could not open" && tFile & ":" && the result |
|
Actually, do we think that the LCB_textEditor preference should take precedence over file association? I think @montegoulding has suggested this in the past. |
Corrected remaining `the result` to `tResult`
| __revIDEDeveloperExtensionSendError "Could not open" && tFile & ":" && tResult | ||
| else if it is not empty then | ||
| # AL-2015-04-01: [[ Bug 15130 ]] If the new text editor launch was successful, set the preference | ||
| revIDESetPreference "LCB_textEditor", it |
There was a problem hiding this comment.
I would like to see this moved up to after line 600 with:
if tResult is empty then
# AL-2015-04-01: [[ Bug 15130 ]] If the new text editor launch was successful, set the preference
revIDESetPreference "LCB_textEditor", it
end if
I don't feel safe that it will be empty if there were already an association.
Relocate storage of new text editor preference to immediately after the launch to ensure `it` contains the intended value
|
If the preference were to take precedence over the file association, then I think there needs to be a way to set/reset the pref in the IDE somewhere (probably a good idea anyway). Could be a menu option on the cog of the Extension Builder stack (palletActions widget) since this is the only place it is used. |
|
Yeah, that's a good idea. I'm not sure exactly what the best way of populating the list of possible programs would be though. |
|
Doing some testing with the additions and found an issue. The result is being set to the app name. |
The following command sequence (in message box):
`put revIDEGetPreference("LCB_textEditor") into tEditor; launch ".../treeviewx.lcb" with tEditor; put the result`
Results in the value of `tEditor` when successful (although success in opening the file is not guaranteed)
Added a check for "no such program" in the case where the specified editor is no longer available
Updated code to use the `tEditor` variable in place of `it` for clarity
Added a check for `tResult` being `tEditor` to not display an error
|
@livecode-vulcan review ok 9a63f32 |
|
💙 review by @montegoulding ok 9a63f32 |
The
revIDEDeveloperExtensionEditScripthandler will open an LCB file in the default editor. It usesthe resultto catch failures to open with a default editor and set a pref. The problem is that after evaluating the nextput(getting the editor pref), the original value is lost. This means that if the pref has not already been set, then the file won't get opened.This change implements a new variable
tResultto carry forward the result though the function.