Preserve editing shortcuts outside multi-pane layouts
This commit is contained in:
@@ -47,6 +47,7 @@ class _ChatWorkspaceState extends State<ChatWorkspace> {
|
||||
|
||||
bool _key(KeyEvent event) {
|
||||
if (!widget.shortcutsEnabled ||
|
||||
widget.controller.paneCount <= 1 ||
|
||||
!_focus.hasFocus ||
|
||||
event is! KeyDownEvent) {
|
||||
return false;
|
||||
|
||||
@@ -268,6 +268,40 @@ void main() {
|
||||
);
|
||||
},
|
||||
);
|
||||
testWidgets(
|
||||
'single-pane composer retains control-shift word selection',
|
||||
(tester) async {
|
||||
final controller = ChatWorkspaceController()..open('one');
|
||||
addTearDown(controller.dispose);
|
||||
final focused = <String>[];
|
||||
await tester.pumpWidget(
|
||||
host(
|
||||
controller,
|
||||
width: 700,
|
||||
height: 500,
|
||||
onFocus: (pane) => focused.add(pane.sessionId),
|
||||
),
|
||||
);
|
||||
final input = find.byKey(const ValueKey('input-one'));
|
||||
await tester.enterText(input, 'one two');
|
||||
final text = tester.widget<TextField>(input).controller!;
|
||||
text.selection = const TextSelection.collapsed(offset: 0);
|
||||
await tester.pump();
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight);
|
||||
await tester.sendKeyUpEvent(LogicalKeyboardKey.shiftLeft);
|
||||
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
|
||||
await tester.pump();
|
||||
expect(text.selection.isCollapsed, isFalse);
|
||||
expect(text.selection.start, 0);
|
||||
expect(text.selection.end, greaterThan(0));
|
||||
expect(text.text, 'one two');
|
||||
expect(focused, isEmpty);
|
||||
},
|
||||
variant: TargetPlatformVariant.only(TargetPlatform.linux),
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'Command Shift arrows navigate on macOS without modifying drafts',
|
||||
(tester) async {
|
||||
|
||||
Reference in New Issue
Block a user