From 283b2312907e0babcdb443f8b62e0aeb0a7ddd51 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ingo=20B=C3=BCrk?= Date: Wed, 15 Apr 2015 19:59:53 +0200 Subject: [PATCH] Disallow moving a container to itself since this would crash i3. --- src/con.c | 5 +++++ testcases/t/243-move-to-mark.t | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/con.c b/src/con.c index a5304553..b82d056a 100644 --- a/src/con.c +++ b/src/con.c @@ -914,6 +914,11 @@ bool con_move_to_mark(Con *con, const char *mark) { target = TAILQ_FIRST(&(target->focus_head)); } + if (con == target) { + DLOG("cannot move the container to itself, aborting.\n"); + return false; + } + return _con_move_to_con(con, target, false, true, false); } diff --git a/testcases/t/243-move-to-mark.t b/testcases/t/243-move-to-mark.t index f3451675..86d71864 100644 --- a/testcases/t/243-move-to-mark.t +++ b/testcases/t/243-move-to-mark.t @@ -268,6 +268,21 @@ sync_with_i3; ($nodes, $focus) = get_ws_content($target_ws); is(@{$nodes}, 1, 'tiling container moved to the target workspace'); +############################################################################### +# Given 'S' and 'M' are the same container, when 'S' is moved to 'M', then +# the command is ignored. +############################################################################### + +$ws = fresh_workspace; +$S = open_window; +$M = $S; +cmd 'mark target'; + +cmd '[id="' . $S->{id} . '"] move container to mark target'; +sync_with_i3; + +does_i3_live; + ############################################################################### done_testing; -- 2.39.5