mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-09-09 14:01:06 +03:00
fix(terminal): keep selection aligned after clearing scrollback (#15831)
Remove scrollback lines through the index-aware buffer operation so deleted anchors are detached and retained lines are reindexed. Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
14
flutter/lib/models/rustdesk_terminal.dart
Normal file
14
flutter/lib/models/rustdesk_terminal.dart
Normal file
@@ -0,0 +1,14 @@
|
||||
import 'package:xterm/xterm.dart';
|
||||
|
||||
class RustDeskTerminal extends Terminal {
|
||||
RustDeskTerminal({super.maxLines});
|
||||
|
||||
@override
|
||||
void eraseScrollbackOnly() {
|
||||
final scrollBack = buffer.scrollBack;
|
||||
if (scrollBack == 0) return;
|
||||
|
||||
// Selection anchors require retained buffer lines to be reindexed.
|
||||
buffer.lines.remove(0, scrollBack);
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import 'package:xterm/xterm.dart';
|
||||
import 'input_modifier_utils.dart';
|
||||
import 'model.dart';
|
||||
import 'platform_model.dart';
|
||||
import 'rustdesk_terminal.dart';
|
||||
import 'terminal_mouse_handler.dart';
|
||||
|
||||
class TerminalModel with ChangeNotifier {
|
||||
@@ -129,7 +130,7 @@ class TerminalModel with ChangeNotifier {
|
||||
}
|
||||
|
||||
TerminalModel(this.parent, [this.terminalId = 0]) : id = parent.id {
|
||||
terminal = Terminal(maxLines: 10000);
|
||||
terminal = RustDeskTerminal(maxLines: 10000);
|
||||
terminal.mouseHandler = const WheelButtonFixMouseHandler();
|
||||
terminalController = TerminalController();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user