Merge pull request #2094 from psychon/fix_rules_no_such_tag
awful.rules: Handle non-existing tags
This commit is contained in:
commit
5b8e8dbf80
|
@ -292,7 +292,13 @@ local force_ignore = {
|
|||
function rules.high_priority_properties.tag(c, value, props)
|
||||
if value then
|
||||
if type(value) == "string" then
|
||||
local name = value
|
||||
value = atag.find_by_name(c.screen, value)
|
||||
if not value then
|
||||
require("gears.debug").print_error("awful.rules-rule specified "
|
||||
.. "tag = '" .. name .. "', but no such tag exists")
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- In case the tag has been forced to another screen, move the client
|
||||
|
|
|
@ -5,6 +5,7 @@ local test_client = require("_client")
|
|||
local unpack = unpack or table.unpack -- luacheck: globals unpack (compatibility with Lua 5.1)
|
||||
|
||||
local callback_called = false
|
||||
local message_printed = false
|
||||
|
||||
-- Magic table to store tests
|
||||
local tests = {}
|
||||
|
@ -46,9 +47,16 @@ local function get_client_by_class(class)
|
|||
end
|
||||
end
|
||||
|
||||
local orig_error = gears.debug.print_error
|
||||
function gears.debug.print_error(msg)
|
||||
assert(not message_printed, msg)
|
||||
assert(msg:find("specified tag = 'does_not_exist', but no such tag exists"), msg)
|
||||
message_printed = true
|
||||
end
|
||||
|
||||
-- Test callback and floating
|
||||
test_rule {
|
||||
properties = { floating = true },
|
||||
properties = { floating = true, tag = "does_not_exist" },
|
||||
callback = function(c)
|
||||
assert(type(c) == "client")
|
||||
callback_called = true
|
||||
|
@ -57,6 +65,10 @@ test_rule {
|
|||
-- Test if callbacks works
|
||||
assert(callback_called)
|
||||
|
||||
-- Test that the "does_not_exist"-tag caused an error
|
||||
assert(message_printed)
|
||||
gears.debug.print_error = orig_error
|
||||
|
||||
-- Make sure "smart" dynamic properties are applied
|
||||
assert(get_client_by_class(class).floating)
|
||||
|
||||
|
|
Loading…
Reference in New Issue