T-205, the resolver foundation for Vim motions (dd, gg, dw, ciw) and repeat counts (5j). KeymapBinding now holds an ordered chord sequence (length 1 for the common single-chord case); `keys:` parses a space- separated spec into that sequence (D-82). Keymap.resolve keeps the single-chord fast path; a new stateless Keymap.match answers exact/prefix/none for a pending buffer. SequenceMatcher wraps that query with a pending buffer, a repeat-count prefix (leading digits, 0 excluded since it's the line-start motion), the d-vs-dd timeout case (flush fires the buffered exact), and broken- sequence recovery (discard, restart on the last chord). It is headless — no keyboard reads, no event swallowing — so the editor (T-206) can drive it from Focus.onKeyEvent and act on the result. Also drops a stray unused import in the Vim indicator test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
58 lines
1.7 KiB
Dart
58 lines
1.7 KiB
Dart
/// T-207: the status-bar mode indicator shows `-- MODE --` while the Vim
|
|
/// layer is enabled and renders nothing otherwise.
|
|
library;
|
|
|
|
import 'package:clide/builtin/vim/vim.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import '../../helpers/kernel_fixture.dart';
|
|
import '../../helpers/widget_harness.dart';
|
|
|
|
void main() {
|
|
late KernelFixture f;
|
|
late VimModeService mode;
|
|
|
|
setUp(() async {
|
|
f = await KernelFixture.create();
|
|
mode = VimModeService(f.services.keymap);
|
|
});
|
|
tearDown(() {
|
|
mode.dispose();
|
|
return f.dispose();
|
|
});
|
|
|
|
testWidgets('renders nothing while disabled', (tester) async {
|
|
await tester.pumpWidget(harness(f, VimModeIndicator(service: mode)));
|
|
await tester.pumpAndSettle();
|
|
expect(find.textContaining('NORMAL'), findsNothing);
|
|
expect(tester.takeException(), isNull);
|
|
});
|
|
|
|
testWidgets('shows the active mode and updates on transition', (tester) async {
|
|
mode.enabled = true;
|
|
await tester.pumpWidget(harness(f, VimModeIndicator(service: mode)));
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('-- NORMAL --'), findsOneWidget);
|
|
|
|
mode.enterInsert();
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('-- INSERT --'), findsOneWidget);
|
|
expect(find.text('-- NORMAL --'), findsNothing);
|
|
|
|
mode.enterVisual();
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('-- VISUAL --'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('disabling hides the indicator', (tester) async {
|
|
mode.enabled = true;
|
|
await tester.pumpWidget(harness(f, VimModeIndicator(service: mode)));
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('-- NORMAL --'), findsOneWidget);
|
|
|
|
mode.enabled = false;
|
|
await tester.pumpAndSettle();
|
|
expect(find.textContaining('NORMAL'), findsNothing);
|
|
});
|
|
}
|