Skip to content
Open
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 docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Template for new versions:
- `buildingplan`: fix roller material estimate asking for one chain per tile instead of one chain total
- `buildingplan`: fix "Unlink all" only unlinking some mechanisms (or crashing) when freeing mechanisms from the building
- `tiletypes`: remove plants (including trees) rooted on a tile that is painted into something that cannot host them, so cleared ground no longer regrows floating trees
- `gui/quickfort`: show smoothing designations immediately after applying a blueprint
- `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
- Fixed persistent site data API (``dfhack.persistent.saveSiteData``/``getSiteData``) failing on newly reclaimed fortresses until the first save
Expand Down
1 change: 1 addition & 0 deletions plugins/lua/dig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ DesignatedOverlay.ATTRS{
'dwarfmode/Designate/TRACK',
'dwarfmode/Designate/FORTIFY',
'dwarfmode/Designate/ERASE',
'dwarfmode/dfhack/lua/quickfort',
},
default_enabled=true,
frame={w=0, h=0},
Expand Down
4 changes: 4 additions & 0 deletions plugins/lua/overlay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,10 @@ local function matches_focus_strings(db_entry, vs_name, vs)
if dfhack.gui.matchFocusString(fs, vs) then
return true
end
local lua_focus = fs:match('^[^/]+/(dfhack/lua/.*)$')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note for posterity: this regex looks okay. it should resolve quickly into a match or not-match.
it is, in general, a bad idea to have two or more unbounded matches such as .* in a regex.
in this case, the regex is clamped to the start and end of the string, and the first subexpression [^/]+ will consume characters up to the first /. no backtracking is possible, and no backtracking would be possible even if this were a true regex instead of Lua's poor-man's regex.

if lua_focus and dfhack.gui.matchFocusString(lua_focus) then
return true
end
end
end
return matched
Expand Down
30 changes: 30 additions & 0 deletions test/plugins/dig.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
config.mode = 'fortress'
config.target = 'dig'

local gui = require('gui')
local overlay = require('plugins.overlay')

local TestScreen = defclass(TestScreen, gui.ZScreen)
TestScreen.ATTRS{focus_path='quickfort'}

function test.ascii_designations_visible_in_quickfort()
require('plugins.dig')
overlay.rescan()
local widget = overlay.get_state().db['dig.asciidesignated'].widget
expect.eq('dwarfmode/dfhack/lua/quickfort',
widget.viewscreens[#widget.viewscreens])

local render = mock.func()
local screen = TestScreen{}
screen:show()
dfhack.with_finalize(
function() screen:dismiss() end,
function()
mock.patch(widget, 'render', render, function()
overlay.render_viewscreen_widgets(
'viewscreen_dwarfmodest',
dfhack.gui.getViewscreenByType(df.viewscreen_dwarfmodest, 0))
end)
end)
expect.eq(1, render.call_count)
end
Loading