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

Commit 9421a12

Browse files
committed
[[ Bug 21202 ]] Fix deselection of next find after replace
This patch adds a method to replace text in the script editor without calling selection update or chaging the selection at all. The current selection update request was causing find results to be cleared between replace and go to next and the subsequent replace.
1 parent e758a1c commit 9421a12

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

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

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ end textReplaceNewGroupNeeded
846846
# This is the point through which all standard editing operations on scripts are sent through.
847847
# Any change made via this function will be added to the undo system. This is called when the
848848
# user types keys, formats text, cuts, pastes etc.
849-
command textReplace pOffset, pOldText, pNewText, pObject, pDontGroup
849+
command textReplace pOffset, pOldText, pNewText, pObject, pDontGroup, pDontSelect
850850
lock screen
851851

852852
local tObject
@@ -943,27 +943,33 @@ command textReplace pOffset, pOldText, pNewText, pObject, pDontGroup
943943
end repeat
944944
put true into sPlaceholders[sEditPlaceholder]["edited"]
945945

946-
if tSelection is not empty then
947-
select tSelection
948-
else if pNewText is empty then
949-
select char pOffset to pOffset-1 of field "script" of me
950-
else if the length of pNewText is 1 then
951-
select char pOffset+1 to pOffset of field "script" of me
952-
else if tBracketCompletionType is "pair" then
953-
select after char pOffset of field "script" of me
946+
if not pDontSelect then
947+
if tSelection is not empty then
948+
select tSelection
949+
else if pNewText is empty then
950+
select char pOffset to pOffset-1 of field "script" of me
951+
else if the length of pNewText is 1 then
952+
select char pOffset+1 to pOffset of field "script" of me
953+
else if tBracketCompletionType is "pair" then
954+
select after char pOffset of field "script" of me
955+
end if
954956
end if
955957
else
956958
-- clear highlighted bracket background color
957959
__ClearHighlights
958960
textReplaceRaw pOffset, pOldText, pNewText
959-
if tSelection is not empty then
960-
select tSelection
961-
else if tBracketCompletionType is "pair" then
962-
select after char pOffset of field "script" of me
961+
if not pDontSelect then
962+
if tSelection is not empty then
963+
select tSelection
964+
else if tBracketCompletionType is "pair" then
965+
select after char pOffset of field "script" of me
966+
end if
963967
end if
964968
end if
965969

966-
selectionUpdateRequest
970+
if not pDontSelect then
971+
selectionUpdateRequest
972+
end if
967973

968974
-- when formatting or pasting we don't want autocomplete to pop up
969975
if the number of lines of pNewText <= 1 then
@@ -3455,6 +3461,10 @@ end __UpdateAutoCompleteList
34553461

34563462
private command __ClearCurrentPlaceholder pForce
34573463
if not pForce then
3464+
if the selectedField is empty or \
3465+
the long id of the selectedField is not the long id of field "script" of me then
3466+
exit __ClearCurrentPlaceholder
3467+
end if
34583468
local tChunk
34593469
put the selectedChunk into tChunk
34603470
if exists(tChunk) then

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2203,7 +2203,7 @@ command replaceOnce pString
22032203
put tFrom into tAt
22042204

22052205
textBeginGroup "Replace"
2206-
textReplace tAt, char tFrom to tTo of textGetScript(), pString
2206+
textReplace tAt, char tFrom to tTo of textGetScript(), pString, , , true
22072207

22082208
# OK-2009-02-16 : Bug 7712 - Return information about the replaced text so that in a the context of replaceOnceAndFind, we can ensure
22092209
# that the replaced text does not get searched.

notes/bugfix-21202.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Fix deselection of next find after replace in Script Editor

0 commit comments

Comments
 (0)