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

Commit 7c94eda

Browse files
committed
[[ Bug 21232 ]] Update breakpoints relative to offset
Previously breakpoints were being updated relative to the selected line rather than the offset of the text change. This patch changes that so that text changes that may not involve the selection move breakpoints correctly.
1 parent d61f964 commit 7c94eda

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ command update pOffset, pSelectedLine, pOldNumber, pNewNumber, pTextChanged, pUp
5454
put tContext["object"] into sLastObject
5555
end if
5656

57-
updateBreakpoints pOffset, pSelectedLine, pOldNumber, pNewNumber, pTextChanged, tContext
57+
updateBreakpoints pOffset, pOldNumber, pNewNumber, pTextChanged, tContext
5858
updateLineNumbers pTextChanged, pOldNumber, pNewNumber, tContext
5959
updateCurrentLine tContext
6060

@@ -390,12 +390,12 @@ end updateCompilationErrors
390390

391391
# Parameters
392392
# pObject : reference to the object to update breakpoint positions for
393-
# pLine : the current line number
393+
# pOffset : the offset of text replacement
394394
# pOldNumber : the number of lines previously in the script
395395
# pNewNumber : the number of lines now in the script
396396
# Description
397397
# Updates the the positions of breakpoints in response to the script being changed.
398-
private command updateBreakpointPositions pObject, pOffset, pLine, pOldNumber, pNewNumber
398+
private command updateBreakpointPositions pObject, pOffset, pOldNumber, pNewNumber
399399
local tNumber, tInsertion
400400

401401
if pOldNumber = pNewNumber then
@@ -405,12 +405,12 @@ private command updateBreakpointPositions pObject, pOffset, pLine, pOldNumber, p
405405
local tBreakpoints
406406
put revDebuggerListBreakpoints(pObject) into tBreakpoints
407407

408+
local tLineIndex
409+
put the lineIndex of char pOffset of getScriptField() into tLineIndex
410+
408411
if pOldNumber < pNewNumber then
409412
repeat for each line tBreakpoint in tBreakpoints
410-
if item -1 of tBreakpoint = pLine then
411-
local tLineIndex
412-
put the lineIndex of char pOffset of getScriptField() into tLineIndex
413-
413+
if item -1 of tBreakpoint = tLineIndex then
414414
local tCharIndex
415415
put the charIndex of line tLineIndex of getScriptField() into tCharIndex
416416

@@ -428,31 +428,31 @@ private command updateBreakpointPositions pObject, pOffset, pLine, pOldNumber, p
428428
end if
429429

430430
# If the line that contained the breakpoint was above the added text, leave it where it is
431-
if item -1 of tBreakpoint < pLine then
431+
if item -1 of tBreakpoint < tLineIndex then
432432
next repeat
433433
end if
434434

435435

436436
# If the line that contained the breakpoint was below the added text, move the breakpoint down by the number of lines added.
437-
if item -1 of tBreakpoint > pLine then
437+
if item -1 of tBreakpoint > tLineIndex then
438438
revDebuggerMoveBreakpoint item 1 to -2 of tBreakpoint, item -1 of tBreakpoint, item 1 to -2 of tBreakpoint, item -1 of tBreakpoint + (pNewNumber - pOldNumber)
439439
end if
440440
end repeat
441441
else
442442
local tScript
443443
put textGetScript() into tScript
444444
repeat for each line tBreakpoint in tBreakpoints
445-
if (item -1 of tBreakpoint >= pLine and item -1 of tBreakpoint < (pLine - (pNewNumber - pOldNumber))) and revDebuggerNextAvailableBreakpoint(tScript, item -1 of tBreakpoint - 1 + (pNewNumber - pOldNumber)) <> item -1 of tBreakpoint + (pNewNumber - pOldNumber) then
445+
if (item -1 of tBreakpoint >= tLineIndex and item -1 of tBreakpoint < (tLineIndex - (pNewNumber - pOldNumber))) and revDebuggerNextAvailableBreakpoint(tScript, item -1 of tBreakpoint - 1 + (pNewNumber - pOldNumber)) <> item -1 of tBreakpoint + (pNewNumber - pOldNumber) then
446446
revDebuggerRemoveBreakpoint item 1 to -2 of tBreakpoint, item -1 of tBreakpoint
447-
else if item -1 of tBreakpoint > (pLine + pNewNumber - pOldNumber) then
447+
else if item -1 of tBreakpoint > (tLineIndex + pNewNumber - pOldNumber) then
448448
# If the breakpoint was below the removed lines, move it up
449449
revDebuggerMoveBreakpoint item 1 to -2 of tBreakpoint, item -1 of tBreakpoint, item 1 to -2 of tBreakpoint, item -1 of tBreakpoint + (pNewNumber - pOldNumber)
450450
end if
451451
end repeat
452452
end if
453453
end updateBreakpointPositions
454454

455-
private command updateBreakpoints pOffset, pSelectedLine, pOldNumber, pNewNumber, pTextChanged, pContext
455+
private command updateBreakpoints pOffset, pOldNumber, pNewNumber, pTextChanged, pContext
456456
clearMutableObjects
457457

458458
local tObject
@@ -468,7 +468,7 @@ private command updateBreakpoints pOffset, pSelectedLine, pOldNumber, pNewNumber
468468
end if
469469

470470
if pTextChanged then
471-
updateBreakpointPositions tObject, pOffset, pSelectedLine, pOldNumber, pNewNumber
471+
updateBreakpointPositions tObject, pOffset, pOldNumber, pNewNumber
472472
end if
473473

474474
# Get a list of the breakpoints set on the current object using revDebuggerListBreakpoints.
@@ -717,7 +717,7 @@ on gutterMouseUp pTarget, pClickLoc
717717

718718
lock screen
719719
clearMutableObjects
720-
updateBreakpoints 1, 1, 1, 1, false
720+
updateBreakpoints 1, 1, 1, false
721721
# OK-2010-02-26: Avoid delays when updating breakpoints by only updating the breakpoints pane
722722
-- sePanesUpdate
723723
seRefreshCurrentPaneIfItsBreakpoints
@@ -757,7 +757,7 @@ on menuPick pItemName
757757

758758
lock screen
759759
clearMutableObjects
760-
updateBreakpoints 1, 1, 1, 1, false
760+
updateBreakpoints 1, 1, 1, false
761761

762762
# OK-2010-02-26: Avoid delays when updating breakpoints by only updating the breakpoints pane
763763
-- sePanesUpdate

0 commit comments

Comments
 (0)