Skip to content

Commit 9cd2c60

Browse files
committed
Clean previous PR
1 parent 4e0f7fa commit 9cd2c60

4 files changed

Lines changed: 12 additions & 10 deletions

File tree

docs/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ Detailed list of changes
196196

197197
- ``edit-in-kitty``: Return exit code from underlying editor process on exit (:iss:`10198`)
198198

199+
- Make erasing last command robust against commands with no output and commands in the scrollback (:pull:`10201`)
200+
199201

200202
0.47.4 [2026-06-15]
201203
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

kitty/fast_data_types.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,7 @@ class Screen:
12611261
def test_commit_write_buffer(self, inp: memoryview, output: memoryview) -> int: ...
12621262
def test_parse_written_data(self, dump_callback: None = None) -> None: ...
12631263
def hyperlink_for_id(self, hyperlink_id: int) -> str: ...
1264-
def erase_last_command(self, include_prompt: bool = True) -> bool: ...
1264+
def erase_last_command(self) -> bool: ...
12651265
def set_progress(self, state: int, percent: int) -> None: ...
12661266
def mark_potential_url_drag(self) -> bool: ...
12671267

kitty/screen.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4599,10 +4599,7 @@ find_cmd_output(Screen *self, OutputOffset *oo, index_type start_screen_y, unsig
45994599
}
46004600

46014601
static PyObject*
4602-
erase_last_command(Screen *self, PyObject *args) {
4603-
int include_prompt = 1; // retained for API compatibility; the prompt block is the unit erased
4604-
if (!PyArg_ParseTuple(args, "|p", &include_prompt)) return NULL;
4605-
(void)include_prompt;
4602+
erase_last_command(Screen *self, PyObject *args UNUSED) {
46064603
if (self->linebuf != self->main_linebuf) Py_RETURN_FALSE;
46074604
Line *line;
46084605
// Erase the most recent command: the prompt block immediately above the
@@ -6244,7 +6241,7 @@ static PyMethodDef methods[] = {
62446241
MND(draw, METH_O)
62456242
MND(apply_sgr, METH_O)
62466243
MND(cursor_position, METH_VARARGS)
6247-
MND(erase_last_command, METH_VARARGS)
6244+
MND(erase_last_command, METH_NOARGS)
62486245
MND(set_window_char, METH_VARARGS)
62496246
MND(set_progress, METH_VARARGS)
62506247
MND(set_mode, METH_VARARGS)

kitty_tests/screen.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,7 +1627,7 @@ def lvco():
16271627
s.draw('before\r\n')
16281628
draw_prompt('p1'), draw_output(2), mark_prompt(), s.draw('partial')
16291629
x = s.cursor.x
1630-
s.erase_last_command(False) # include_prompt is now a no-op: the prompt block is the unit erased
1630+
s.erase_last_command()
16311631
self.ae('before\npartial', at().rstrip())
16321632
for scroll in (8, 9, 10):
16331633
s.reset()
@@ -1655,9 +1655,12 @@ def lvco():
16551655
s.reset()
16561656
s.draw('before\r\n')
16571657
draw_prompt('p1'), draw_output(1), draw_prompt('e1'), draw_prompt('e2'), mark_prompt(), s.draw('partial')
1658-
s.erase_last_command(); self.ae('before\n$ p1\n0\n$ e1\npartial', at().rstrip())
1659-
s.erase_last_command(); self.ae('before\n$ p1\n0\npartial', at().rstrip())
1660-
s.erase_last_command(); self.ae('before\npartial', at().rstrip())
1658+
s.erase_last_command()
1659+
self.ae('before\n$ p1\n0\n$ e1\npartial', at().rstrip())
1660+
s.erase_last_command()
1661+
self.ae('before\n$ p1\n0\npartial', at().rstrip())
1662+
s.erase_last_command()
1663+
self.ae('before\npartial', at().rstrip())
16611664
# multi-line live prompt: the command region is erased with no residual
16621665
s.reset()
16631666
s.draw('before\r\n')

0 commit comments

Comments
 (0)