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

Commit 83ee531

Browse files
committed
[[ Bug 21232 ]] Fix wandering breakpoints
This patch fixes wandering breakpoints when undoing a paste or rapidly adding or demoving lines via return or delete. It ensures that we immediately update breakpoints unless the line count as not been changed by the edit.
1 parent 4cf138e commit 83ee531

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

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

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ end textReplaceRawInVariable
10181018
# This is the raw replacement operation that performs a mutation on the script field without
10191019
# saving any undo information. This should be called only from inside textReplace, when doing an undo or a redo
10201020
# and when setting the script when a new object is loaded.
1021-
private command textReplaceRaw pOffset, @pOldText, @pNewText, pDontUpdateBreakpoints
1021+
private command textReplaceRaw pOffset, @pOldText, @pNewText, pDontUpdateBreakpoints, pUpdateBreakpointsNow
10221022
lock screen
10231023
lock messages
10241024

@@ -1044,15 +1044,14 @@ private command textReplaceRaw pOffset, @pOldText, @pNewText, pDontUpdateBreakpo
10441044
add 1 to tNewLines
10451045
end if
10461046
end if
1047+
unlock messages
10471048

10481049
if pDontUpdateBreakpoints then
1049-
updateGutterRequest empty, empty, tOldLines, tNewLines, false, false
1050+
updateGutterRequest empty, empty, tOldLines, tNewLines, false, false, false, pUpdateBreakpointsNow
10501051
else
1051-
updateGutterRequest pOffset, tSelectedLine, tOldLines, tNewLines, true, false
1052+
updateGutterRequest pOffset, tSelectedLine, tOldLines, tNewLines, true, false, false, pUpdateBreakpointsNow
10521053
end if
10531054

1054-
unlock messages
1055-
10561055
# OK-2008-09-10 : Bug 7132 - Update the panes and handler list everytime the text of the field is changed.
10571056
# OK-2009-01-19 : Don't do this here as it slows down the script editor on OS X. Instead do it in the individual
10581057
# cases where it may be needed, cut, paste, return, delete, backspace, undo and redo
@@ -1086,12 +1085,13 @@ on textUndo
10861085

10871086
local tOperations
10881087
put sTextGroupLengths[sObjectId,sTextGroupIndex[sObjectId]] into tOperations
1088+
10891089
lock screen
10901090
repeat with tIndex = sTextOperationIndex[sObjectId] down to sTextOperationIndex[sObjectId] - tOperations + 1
10911091
local tNewText, tOldText
10921092
put sTextOperationNewTexts[sObjectId,tIndex] into tNewText
10931093
put sTextOperationOldTexts[sObjectId,tIndex] into tOldText
1094-
textReplaceRaw sTextOperationOffsets[sObjectId,tIndex], tNewText, tOldText
1094+
textReplaceRaw sTextOperationOffsets[sObjectId,tIndex], tNewText, tOldText, false, true
10951095
end repeat
10961096
unlock screen
10971097

@@ -1123,7 +1123,7 @@ on textRedo
11231123
local tNewText, tOldText
11241124
put sTextOperationOldTexts[sObjectId,tIndex] into tOldText
11251125
put sTextOperationNewTexts[sObjectId,tIndex] into tNewText
1126-
textReplaceRaw sTextOperationOffsets[sObjectId,tIndex], tOldText, tNewText
1126+
textReplaceRaw sTextOperationOffsets[sObjectId,tIndex], tOldText, tNewText, false, true
11271127
end repeat
11281128
unlock screen
11291129

@@ -1235,6 +1235,12 @@ end getUpdateGutterRequestDetails
12351235
# mutable objects (the breakpoint / compilation error images). These are show again when the update is
12361236
# actually carried out.
12371237
command updateGutterRequest pOffset, pSelectedLine, pOldLines, pNewLines, pTextChanged, pUpdateCompilationErrors, pForceBreakpointRedraw, pNow
1238+
if sGutterUpdateRequestDetails["offset"] is not empty and \
1239+
pOffset is not sGutterUpdateRequestDetails["offset"] then
1240+
-- if the offset is different we can't merge
1241+
updateGutterDo
1242+
end if
1243+
12381244
updateGutterMergeRequestDetails pOffset, pSelectedLine, pOldLines, pNewLines, pTextChanged, pUpdateCompilationErrors, pForceBreakpointRedraw
12391245
if sGutterUpdateRequest is not empty then
12401246
cancel sGutterUpdateRequest
@@ -1248,7 +1254,7 @@ command updateGutterRequest pOffset, pSelectedLine, pOldLines, pNewLines, pTextC
12481254
set the vScroll of field "Numbers" of group "Gutter" to the vScroll of field "Script" of me
12491255
end if
12501256

1251-
if pNow then
1257+
if pNow or (pOldLines is not 1 or pNewLines is not 1) then
12521258
updateGutterDo
12531259
else
12541260
send "updateGutterDo" to me in 200 milliseconds
@@ -2071,7 +2077,7 @@ on scrollBarDrag
20712077
lock screen
20722078
put tVScroll into sVScroll
20732079

2074-
updateGutterRequest empty, empty, empty, empty, false, true, empty, true
2080+
updateGutterRequest empty, empty, empty, empty, false, true, false, true
20752081
unlock screen
20762082
end scrollBarDrag
20772083

notes/bugfix-21232.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Fix wandering breakpoints when undoing paste

0 commit comments

Comments
 (0)