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 changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Template for new versions:
- `caravan`: fix doubled "total value of items marked for trade" after toggling filter options, and keep item marks when switching between filter views in the ``Bring goods to depot`` overlay
- `fix/loyaltycascade`: guard against citizens that are not historical figures and emit a warning.
- `gui/siegemanager`: fix nil index if there are no siege engines on the map
- `source`: report a useful error when no keyboard cursor is active

## Misc Improvements
- `caravan`: the ``Bring goods to depot``, ``Trade``, and ``Assign items for display`` overlays now allow searching for items with non-ASCII characters in their description
Expand Down
2 changes: 1 addition & 1 deletion source.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ function main(args)
end

local targetPos = guidm.getCursorPos()
local index = find_liquid_source_at_pos(targetPos)

if command == 'delete' then
if not targetPos then
qerror("Please place the cursor where there is a source to delete")
end
local index = find_liquid_source_at_pos(targetPos)
if index then
delete_liquid_source(targetPos)
print(('Deleted source at %s'):format(formatPos(targetPos)))
Expand Down
23 changes: 23 additions & 0 deletions test/source.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
config = {
mode = 'fortress',
target = 'source',
}

local guidm = require('gui.dwarfmode')
local source = reqscript('source')

function test.delete_requires_cursor()
mock.patch(guidm, 'getCursorPos', function() end, function()
expect.error_match(
'Please place the cursor where there is a source to delete',
function() source.main{'delete'} end)
end)
end

function test.add_requires_cursor()
mock.patch(guidm, 'getCursorPos', function() end, function()
expect.error_match(
'Please place the cursor where you would like a source',
function() source.main{'add', 'water'} end)
end)
end