The first T-197 fix flipped the wrong lever: it called activateTab(Slots.workspace, 'editor.active'), but _WorkspaceSlot renders its editor split off arrangement.editorOpen — not the active tab — so clicking a file still showed nothing. Call arrangement .openEditor() on editor.opened / active-changed(non-null), and closeEditor() on active-changed(null) so the split collapses when the last buffer closes. Test now asserts arrangement.editorOpen, the lever the UI actually reads. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
70 lines
2.6 KiB
Dart
70 lines
2.6 KiB
Dart
/// T-197: EditorExtension opens the workspace editor split when a buffer
|
|
/// opens and collapses it when the last one closes.
|
|
///
|
|
/// The workspace renders its editor split off `arrangement.editorOpen`
|
|
/// (not the active tab), so the extension must flip that flag — otherwise
|
|
/// `editor.open` opens the buffer daemon-side but nothing appears over
|
|
/// the Claude pane.
|
|
library;
|
|
|
|
import 'package:clide/builtin/editor/src/extension.dart';
|
|
import 'package:clide/kernel/kernel.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import '../../helpers/kernel_fixture.dart';
|
|
|
|
void main() {
|
|
late KernelFixture f;
|
|
|
|
setUp(() async {
|
|
f = await KernelFixture.create();
|
|
f.services.extensions.register(EditorExtension());
|
|
await f.services.extensions.activate('builtin.editor');
|
|
});
|
|
tearDown(() => f.dispose());
|
|
|
|
void emitEditor(String kind, {String? id}) {
|
|
f.services.events.emit(DaemonEvent(subsystem: 'editor', kind: kind, data: {'id': id}, ts: DateTime.now().toUtc()));
|
|
}
|
|
|
|
test('contributes the editor.active workspace tab', () {
|
|
expect(f.services.panels.tabsFor(Slots.workspace).any((t) => t.id == 'editor.active'), isTrue);
|
|
});
|
|
|
|
test('editor.opened opens the editor split', () async {
|
|
expect(f.services.arrangement.editorOpen, isFalse);
|
|
emitEditor('editor.opened', id: 'b_1');
|
|
await Future<void>.delayed(Duration.zero);
|
|
expect(f.services.arrangement.editorOpen, isTrue);
|
|
});
|
|
|
|
test('editor.active-changed with a buffer keeps the split open', () async {
|
|
emitEditor('editor.active-changed', id: 'b_2');
|
|
await Future<void>.delayed(Duration.zero);
|
|
expect(f.services.arrangement.editorOpen, isTrue);
|
|
});
|
|
|
|
test('editor.active-changed with a null id collapses the split', () async {
|
|
emitEditor('editor.opened', id: 'b_1');
|
|
await Future<void>.delayed(Duration.zero);
|
|
expect(f.services.arrangement.editorOpen, isTrue);
|
|
|
|
emitEditor('editor.active-changed', id: null);
|
|
await Future<void>.delayed(Duration.zero);
|
|
expect(f.services.arrangement.editorOpen, isFalse);
|
|
});
|
|
|
|
test('a non-editor event does not open the split', () async {
|
|
f.services.events.emit(DaemonEvent(subsystem: 'git', kind: 'changed', data: const {}, ts: DateTime.now().toUtc()));
|
|
await Future<void>.delayed(Duration.zero);
|
|
expect(f.services.arrangement.editorOpen, isFalse);
|
|
});
|
|
|
|
test('after deactivate, editor events no longer open the split', () async {
|
|
await f.services.extensions.deactivate('builtin.editor');
|
|
emitEditor('editor.opened', id: 'b_9');
|
|
await Future<void>.delayed(Duration.zero);
|
|
expect(f.services.arrangement.editorOpen, isFalse);
|
|
});
|
|
}
|