Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions extensions/widgets/treeview/notes/21503.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# [21503] Prevent accidental value removal on key addition
18 changes: 16 additions & 2 deletions extensions/widgets/treeview/treeview.lcb
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ public handler OnMouseDown() returns nothing
end if
end handler

public handler OnMouseMove() returns nothing
public handler OnMouseMove() returns nothing
if scrollDragging() then
variable tScrollPositionRatio as Real
scrollbarDrag(mViewHeight)
Expand Down Expand Up @@ -1509,9 +1509,23 @@ private handler addKey(in pListElt as Integer, in pPath as List, in pLevel as In
if tElement is an array then
createNewKey(xArray[pPath[pLevel + 1]])
else
if tElement is not "" then
variable tPrompt as String
combine pPath with "]["
put "The array element at path [" & the result & "] is not empty. " & \
"Would you like to replace it with an empty array or " & \
"move it to the first element?" into tPrompt
execute script "answer \q" & tPrompt & \
"\q with Cancel or Replace or Move; return it"
if the result is "Replace" then
put "" into tElement
else if the result is "Cancel" then
return
end if
end if
variable tArray as Array
put the empty array into tArray
put "" into tArray[1 formatted as string]
put tElement into tArray[1 formatted as string]
put tArray into xArray[pPath[pLevel + 1]]
put false into xList[pListElt]["leaf"]
end if
Expand Down