Files
clide/test/kernel/recent_files_test.dart
T
jpmschweitzerandClaude Opus 4.8 0c7a6e86d5 add quick-open fuzzy file finder (Ctrl/Cmd+P)
A file picker overlay over the whole workspace, distinct from the
command palette. QuickOpenController holds the file list + a
subsequence fuzzy filter; the overlay loads the list via files.walk on
open, shows RecentFilesService entries on an empty query, and opens the
selection through a shared openWorkspaceFile helper (.md → markdown
reader bus, else editor.open) that the files panel now also routes
through, so recents stay in sync from every open site.

Bound to ctrl+p / meta+p with `when: !palette.open` so it never
collides with the palette's ctrl+p navigation; in-overlay arrows/enter/
escape reuse the palette's keymap-driven model via quickOpen.* intents.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-31 20:19:21 +02:00

57 lines
1.5 KiB
Dart

/// Unit tests for [RecentFilesService] — the session-scoped recent
/// files list backing quick-open's empty-query state (T-51).
library;
import 'package:clide/kernel/src/recent_files.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
test('push records most-recent-first', () {
final r = RecentFilesService();
r.push('a.dart');
r.push('b.dart');
expect(r.paths, ['b.dart', 'a.dart']);
});
test('push de-duplicates and moves an existing entry to the front', () {
final r = RecentFilesService();
r.push('a.dart');
r.push('b.dart');
r.push('a.dart');
expect(r.paths, ['a.dart', 'b.dart']);
});
test('trims to the cap, dropping the oldest', () {
final r = RecentFilesService(cap: 2);
r.push('a');
r.push('b');
r.push('c');
expect(r.paths, ['c', 'b']);
});
test('empty path is ignored', () {
final r = RecentFilesService();
r.push('');
expect(r.paths, isEmpty);
});
test('clear empties the list and notifies once', () {
final r = RecentFilesService();
var notifications = 0;
r.addListener(() => notifications++);
r.push('a');
r.clear();
expect(r.paths, isEmpty);
expect(notifications, 2);
// A second clear on an empty list is a no-op (no extra notify).
r.clear();
expect(notifications, 2);
});
test('paths is an unmodifiable snapshot', () {
final r = RecentFilesService();
r.push('a');
expect(() => r.paths.add('b'), throwsUnsupportedError);
});
}