command: silently ignore re-declaring a mode

This change is made in the interest of allowing users to simply re-run
their init script at runtime without errors. Making this an error
doesn't really gain us anything.
This commit is contained in:
Isaac Freund 2021-02-14 18:13:15 +01:00
parent 5c0be25142
commit 6470d8c776
No known key found for this signature in database
GPG key ID: 86DED400DDFD7A11

View file

@ -37,14 +37,7 @@ pub fn declareMode(
const config = &seat.input_manager.server.config;
const new_mode_name = args[1];
if (config.mode_to_id.get(new_mode_name) != null) {
out.* = try std.fmt.allocPrint(
allocator,
"mode '{}' already exists and cannot be re-declared",
.{new_mode_name},
);
return Error.Other;
}
if (config.mode_to_id.get(new_mode_name) != null) return;
try config.modes.ensureCapacity(config.modes.items.len + 1);
const owned_name = try std.mem.dupe(util.gpa, u8, new_mode_name);