Skip to content

Commit e89acec

Browse files
authored
Sort systems by duration in Debugger (#150)
1 parent 03e6dd6 commit e89acec

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ The format is based on [Keep a Changelog][kac], and this project adheres to
1010

1111
## [Unreleased]
1212

13+
### Added
14+
15+
- Added a button to the Debugger's system list to sort by run time.
16+
1317
### Fixed
1418

1519
- The debugger now gracefully handles cyclic tables.

lib/debugger/ui.luau

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,17 @@ local function ui(debugger, loop)
126126
end
127127
end
128128

129+
local sortByDuration, setSortByDuration = plasma.useState(false)
130+
129131
plasma.space(15)
130-
plasma.heading("SYSTEMS")
132+
plasma.row({ verticalAlignment = Enum.VerticalAlignment.Center }, function()
133+
plasma.heading("SYSTEMS")
134+
135+
if plasma.button(`sort by: {sortByDuration and "duration" or "order"}`):clicked() then
136+
setSortByDuration(not sortByDuration)
137+
end
138+
end)
139+
131140
plasma.space(10)
132141

133142
local durations = {}
@@ -198,6 +207,12 @@ local function ui(debugger, loop)
198207
})
199208
end
200209

210+
if sortByDuration then
211+
table.sort(listOfSystems, function(a, b)
212+
return (durations[a.system] or 0) > (durations[b.system] or 0)
213+
end)
214+
end
215+
201216
local systemList = custom.selectionList(listOfSystems, custom)
202217
local selected = systemList:selected()
203218
local rightClicked = systemList:rightClicked()

lib/debugger/widgets/selectionList.luau

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,10 @@ return function(Plasma)
127127

128128
Plasma.useEffect(function()
129129
refs.mainText.Text = text
130+
refs.index.Text = index or ""
130131
refs.button.container.Icon.Text = icon or ""
131132
refs.button.container.Icon.Visible = icon ~= nil
132-
end, text, icon)
133+
end, text, icon, index)
133134

134135
refs.button.container.sideText.Visible = sideText ~= nil
135136
refs.button.container.sideText.Text = if sideText ~= nil then sideText else ""

0 commit comments

Comments
 (0)