Introduce EditorSettings as the effective, source-agnostic editor configuration the editor and save path obey. .editorconfig is demoted to one *source* (editorconfig.dart now returns EditorSettings); editor_settings_resolver.dart is the single composition seam where future sources — a settings panel, a clide settings file — layer in via merge() without the editor changing. The registry resolves settings on buffer load and, when a .editorconfig is saved in-app, re-resolves every open buffer and emits editor.settings-changed (a hook in save, not a filesystem watcher — the realistic case, cheaply). Buffer JSON carries editorSettings. 100% line coverage on the new model + resolver. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
24 lines
806 B
Dart
24 lines
806 B
Dart
import 'dart:io';
|
|
|
|
import 'package:clide/src/editor/editor_settings_resolver.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
void main() {
|
|
group('resolveEditorSettings', () {
|
|
late Directory root;
|
|
setUp(() async => root = await Directory.systemTemp.createTemp('clide-ec-resolve-'));
|
|
tearDown(() => root.deleteSync(recursive: true));
|
|
|
|
test('composes from the .editorconfig source', () async {
|
|
await File('${root.path}/.editorconfig').writeAsString('root = true\n[*]\nindent_style = space\nindent_size = 2\n');
|
|
final s = resolveEditorSettings(root, 'lib/a.dart');
|
|
expect(s.indentStyle, 'space');
|
|
expect(s.indentSize, 2);
|
|
});
|
|
|
|
test('no source resolves to empty settings', () async {
|
|
expect(resolveEditorSettings(root, 'a.txt').isEmpty, isTrue);
|
|
});
|
|
});
|
|
}
|