From 4e3c712d8488d3d6e462d84ee519a70b556d18f5 Mon Sep 17 00:00:00 2001 From: Alistair-Afton Date: Wed, 16 Sep 2026 04:41:21 +0200 Subject: [PATCH 1/2] sort: include real building display names in places/task search keys Searching the Places/Workshops list for 'Stoneworker's Workshop' found nothing because the search key was built from the enum item name and a stale df-structures name attr. Add each workshop's getName() output to the search key so searches match what the list actually displays, and cover custom workshop names (e.g. 'Screw Press') that have no enum attr at all. --- docs/changelog.txt | 1 + plugins/lua/sort/info.lua | 6 ++++++ plugins/lua/sort/places.lua | 8 ++++++++ 3 files changed, 15 insertions(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index e078c870da..aeec3aa2eb 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -71,6 +71,7 @@ Template for new versions: - `aquifer`: make ``--skip-top`` and top-relative ``--levels`` take effect for the ``drain``, ``convert``, and ``add`` actions instead of being silently ignored - `autodump`: ``destroy`` no longer leaves the contents of destroyed containers in limbo or crashes when destroying unit-held items - `buildingplan`: fix "Unlink all" only unlinking some mechanisms (or crashing) when freeing mechanisms from the building +- `sort`: fix the Places/Workshops and task searches missing workshops by their current display names (e.g. "Stoneworker's Workshop", "Screw Press") - `timestream`: deal properly with units who have breathing difficulties - `stocks`: overlay now resets scroll position when collapsing categories so the item list is no longer left blank and unscrollable diff --git a/plugins/lua/sort/info.lua b/plugins/lua/sort/info.lua index 4f0462dfb7..93257e7e29 100644 --- a/plugins/lua/sort/info.lua +++ b/plugins/lua/sort/info.lua @@ -29,6 +29,12 @@ local function get_task_search_key(cri_unit) table.insert(result, bld.name) local btype = bld:getType() if btype == df.building_type.Workshop then + -- the display name may differ from the enum item name (e.g. + -- Masons -> "Stoneworker's Workshop") and is the raw-defined + -- name for custom workshops + local name = df.new('string') + bld:getName(name) + table.insert(result, name.value) table.insert(result, df.workshop_type.attrs[bld.type].name or '') table.insert(result, df.workshop_type[bld.type]) elseif btype == df.building_type.Furnace then diff --git a/plugins/lua/sort/places.lua b/plugins/lua/sort/places.lua index c353d5a948..aa61a53f35 100644 --- a/plugins/lua/sort/places.lua +++ b/plugins/lua/sort/places.lua @@ -153,6 +153,14 @@ local function get_workshop_search_key(workshop) end table.insert(result, workshop.name) + + -- the display name may differ from the enum item name (e.g. Masons -> + -- "Stoneworker's Workshop") and is the raw-defined name for custom + -- workshops + local name = df.new('string') + workshop:getName(name) + table.insert(result, name.value) + table.insert(result, df.workshop_type.attrs[workshop.type].name or '') table.insert(result, df.workshop_type[workshop.type]) From 1138e90a2fee117682ba78d9db8af85c1fe86047 Mon Sep 17 00:00:00 2001 From: Alistair-Afton Date: Thu, 17 Sep 2026 18:49:09 +0200 Subject: [PATCH 2/2] use dfhack.buildings.getName instead of leaking df.new strings --- plugins/lua/sort/info.lua | 4 +--- plugins/lua/sort/places.lua | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/plugins/lua/sort/info.lua b/plugins/lua/sort/info.lua index 93257e7e29..413b51f249 100644 --- a/plugins/lua/sort/info.lua +++ b/plugins/lua/sort/info.lua @@ -32,9 +32,7 @@ local function get_task_search_key(cri_unit) -- the display name may differ from the enum item name (e.g. -- Masons -> "Stoneworker's Workshop") and is the raw-defined -- name for custom workshops - local name = df.new('string') - bld:getName(name) - table.insert(result, name.value) + table.insert(result, dfhack.buildings.getName(bld)) table.insert(result, df.workshop_type.attrs[bld.type].name or '') table.insert(result, df.workshop_type[bld.type]) elseif btype == df.building_type.Furnace then diff --git a/plugins/lua/sort/places.lua b/plugins/lua/sort/places.lua index aa61a53f35..2b42be60c3 100644 --- a/plugins/lua/sort/places.lua +++ b/plugins/lua/sort/places.lua @@ -157,9 +157,7 @@ local function get_workshop_search_key(workshop) -- the display name may differ from the enum item name (e.g. Masons -> -- "Stoneworker's Workshop") and is the raw-defined name for custom -- workshops - local name = df.new('string') - workshop:getName(name) - table.insert(result, name.value) + table.insert(result, dfhack.buildings.getName(workshop)) table.insert(result, df.workshop_type.attrs[workshop.type].name or '') table.insert(result, df.workshop_type[workshop.type])