From f0b6a71a659bd339e13aeada72a618b2507b067a Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 29 Jul 2026 06:40:37 +0800 Subject: [PATCH] fix: Delete key in terminal deleting prompt text (root@host) _on_delete() was missing _current_line_start check that _on_backspace already had. Clicking into the prompt area (root@hostname:~#) and pressing Delete would erase prompt characters. Now: - Cursor before input line: moved to input start, no deletion - Selection crossing prompt boundary: blocked --- ui/terminal_panel.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ui/terminal_panel.py b/ui/terminal_panel.py index e660410..a7bd02c 100644 --- a/ui/terminal_panel.py +++ b/ui/terminal_panel.py @@ -583,8 +583,16 @@ class TerminalPanel(QWidget): cursor = self.term.textCursor() if cursor.atEnd(): return - if cursor.columnNumber() == 0 and not cursor.hasSelection(): + # 不允许删除当前输入行之前的内容(提示符 root@host:~# 等) + if cursor.position() < self._current_line_start: + cursor.setPosition(self._current_line_start) + self.term.setTextCursor(cursor) return + # 如果有选区且选区起点在当前输入行之前,不允许 + if cursor.hasSelection(): + sel_start = cursor.selectionStart() + if sel_start < self._current_line_start: + return cursor.deleteChar() def _history_prev(self):