Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 5680dc9

Browse files
Merge pull request #1663 from livecode/feature-default_handlers
[[ DefaultHandlers ]] Make sure textSetScriptRaw is still always called
2 parents 418bdb1 + 0788c59 commit 5680dc9

3 files changed

Lines changed: 20 additions & 14 deletions

File tree

Toolset/palettes/script editor/behaviors/revseeditorbehavior.livecodescript

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -330,16 +330,14 @@ command loadScript
330330
# If there is a cached script, this means that the user is coming back to this object from another tab.
331331
textSetScriptRaw tCachedScript
332332
else
333-
# If the object has no script, get the default script for it, otherwise the current script is used
334-
if the script of sObjectId is not empty then
335-
local tScript
336-
put the script of sObjectId into tScript
337-
338-
textSetScriptRaw tScript
339-
340-
# OK-2008-07-07 : Bug 6746
341-
seUpdateCheckSum sObjectId, tScript
342-
else
333+
local tScript
334+
put the script of sObjectId into tScript
335+
336+
textSetScriptRaw tScript
337+
338+
# OK-2008-07-07 : Bug 6746
339+
seUpdateCheckSum sObjectId, tScript
340+
if tScript is empty then
343341
select before field "Script" of me
344342
end if
345343
end if

Toolset/palettes/script editor/behaviors/revsehandlerlistbehavior.livecodescript

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ command resize
259259
unlock screen
260260
end resize
261261

262-
command jumpToHandler pHandler
262+
command jumpToHandler pHandler, pAdded
263263
local tLineNumber
264264
put word 3 of pHandler into tLineNumber
265265

@@ -268,7 +268,7 @@ command jumpToHandler pHandler
268268
set the cChoice of me to tLineNumber & comma & word 2 of pHandler & comma & word 1 of pHandler
269269

270270
if the cCallback of me is not empty then
271-
send the cCallback of me to the cCallbackTarget of me
271+
send the cCallback of me && pAdded to the cCallbackTarget of me
272272
end if
273273

274274
hideGroup
@@ -279,7 +279,10 @@ command closeAccept
279279
local tHandler
280280
put line (the hilitedLine of field "Handlers" of me) of the cHandlers of field "Handlers" of me into tHandler
281281

282+
local tAdded
283+
put false into tAdded
282284
if the number of words in tHandler is 1 then
285+
put true into tAdded
283286
-- Adding a default handler
284287
revSEAddDefaultHandler tHandler
285288
update
@@ -291,7 +294,7 @@ command closeAccept
291294
end if
292295

293296
-- Select the (now) extant handler
294-
jumpToHandler tHandler
297+
jumpToHandler tHandler, tAdded
295298

296299
unlock screen
297300
end closeAccept

Toolset/palettes/script editor/behaviors/revseleftbarbehavior.livecodescript

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ end updateSelectedHandler
9898
# Description
9999
# Callback for the handler list object. This is called when the stack is closed
100100
# which either means the user has chosen a handler, or dismissed the stack.
101-
on handlerSelected
101+
on handlerSelected pNewlyAdded
102102
local tObject
103103
put the long id of group "Left Handler List" of me into tObject
104104

@@ -115,6 +115,11 @@ on handlerSelected
115115
# the handler correctly we call this function which will check if tLine is wrong, and attempt to adjust it.
116116
put seLocateHandler(tHandler, tLine, tType) into tLine
117117

118+
-- If we just added this handler, select at the (empty) line after the handler decl.
119+
if pNewlyAdded then
120+
add 1 to tLine
121+
end if
122+
118123
send "goLine tLine, true" to group "Editor"
119124
seUpdateToolbar
120125
end handlerSelected

0 commit comments

Comments
 (0)