Skip to content

Commit e115eaf

Browse files
committed
Ops(fix): Correct move-window -k and paste-buffer -r
why: An adversarial review of the new ops against tmux's command grammar found two defects: move-window could not request its kill-on-collision behavior, and paste-buffer's -r flag was documented as a space replacement it never performs. what: - MoveWindow: add kill (-k) field; tmux move-window's option string is "abdkrs:t:" and -k replaces any window already at the destination index - PasteBuffer: rename no_format to no_replace and fix the docstring; -r keeps linefeeds instead of converting them to the default carriage-return separator (it has nothing to do with spaces) - Add render cases for move-window -k/-r and paste-buffer -r
1 parent c2f234f commit e115eaf

4 files changed

Lines changed: 25 additions & 4 deletions

File tree

src/libtmux/experimental/ops/_ops/move_window.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ class MoveWindow(Operation[AckResult]):
2424
Do not change the active window (``-d``).
2525
before, after : bool
2626
Insert before (``-b``) or after (``-a``) the destination index.
27+
kill : bool
28+
Replace (kill) any window already at the destination (``-k``).
2729
renumber : bool
2830
Renumber windows to close gaps (``-r``).
2931
@@ -44,6 +46,7 @@ class MoveWindow(Operation[AckResult]):
4446
detach: bool = False
4547
before: bool = False
4648
after: bool = False
49+
kill: bool = False
4750
renumber: bool = False
4851

4952
def args(self, *, version: str | None = None) -> tuple[str, ...]:
@@ -55,6 +58,8 @@ def args(self, *, version: str | None = None) -> tuple[str, ...]:
5558
out.append("-b")
5659
if self.after:
5760
out.append("-a")
61+
if self.kill:
62+
out.append("-k")
5863
if self.renumber:
5964
out.append("-r")
6065
out.extend(self.src_args())

src/libtmux/experimental/ops/_ops/paste_buffer.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ class PasteBuffer(Operation[AckResult]):
2525
Delete the buffer after pasting (``-d``).
2626
bracket : bool
2727
Use bracketed paste mode (``-p``).
28-
no_format : bool
29-
Do not replace separators with spaces (``-r``).
28+
no_replace : bool
29+
Do no separator replacement: keep linefeeds (LF) instead of
30+
converting them to the default carriage-return separator (``-r``).
3031
separator : str or None
3132
Separator inserted between lines (``-s``).
3233
@@ -49,7 +50,7 @@ class PasteBuffer(Operation[AckResult]):
4950
buffer_name: str | None = None
5051
delete: bool = False
5152
bracket: bool = False
52-
no_format: bool = False
53+
no_replace: bool = False
5354
separator: str | None = None
5455

5556
def args(self, *, version: str | None = None) -> tuple[str, ...]:
@@ -59,7 +60,7 @@ def args(self, *, version: str | None = None) -> tuple[str, ...]:
5960
out.append("-d")
6061
if self.bracket:
6162
out.append("-p")
62-
if self.no_format:
63+
if self.no_replace:
6364
out.append("-r")
6465
if self.buffer_name is not None:
6566
out.extend(("-b", self.buffer_name))

tests/experimental/ops/test_buffer_ops.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ class RenderCase(t.NamedTuple):
8282
op=PasteBuffer(target=PaneId("%1"), delete=True),
8383
expected=("paste-buffer", "-t", "%1", "-d"),
8484
),
85+
RenderCase(
86+
test_id="paste_buffer_no_replace",
87+
op=PasteBuffer(target=PaneId("%1"), no_replace=True),
88+
expected=("paste-buffer", "-t", "%1", "-r"),
89+
),
8590
RenderCase(
8691
test_id="show_buffer",
8792
op=ShowBuffer(buffer_name="b0"),

tests/experimental/ops/test_window_ops.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,16 @@ class RenderCase(t.NamedTuple):
9797
op=MoveWindow(target=SessionId("$0"), src_target=WindowId("@2")),
9898
expected=("move-window", "-t", "$0", "-s", "@2"),
9999
),
100+
RenderCase(
101+
test_id="move_window_kill_renumber",
102+
op=MoveWindow(
103+
target=SessionId("$0"),
104+
src_target=WindowId("@2"),
105+
kill=True,
106+
renumber=True,
107+
),
108+
expected=("move-window", "-t", "$0", "-k", "-r", "-s", "@2"),
109+
),
100110
RenderCase(
101111
test_id="link_window",
102112
op=LinkWindow(target=SessionId("$0"), src_target=WindowId("@2")),

0 commit comments

Comments
 (0)