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
This commit is contained in:
@@ -583,7 +583,15 @@ class TerminalPanel(QWidget):
|
|||||||
cursor = self.term.textCursor()
|
cursor = self.term.textCursor()
|
||||||
if cursor.atEnd():
|
if cursor.atEnd():
|
||||||
return
|
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
|
return
|
||||||
cursor.deleteChar()
|
cursor.deleteChar()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user