From 93ec4e41d1dc69a19e0af57c98ba1d873d554a78 Mon Sep 17 00:00:00 2001 From: ZhuchkaTriplesix Date: Sun, 25 Oct 2026 15:49:52 +0300 Subject: [PATCH] fix(debug): theme warnings only for keys no parser reads; the refresh rate is logged once it is known --- lib/core/motion/display_refresh_service.dart | 9 ++++-- .../querya_editor_theme_from_manifest.dart | 10 +++++-- .../querya_workbench_theme_from_manifest.dart | 13 ++++---- ...uerya_editor_theme_from_manifest_test.dart | 30 +++++++++++++++++++ 4 files changed, 49 insertions(+), 13 deletions(-) diff --git a/lib/core/motion/display_refresh_service.dart b/lib/core/motion/display_refresh_service.dart index 64d69f3a..dfafde6a 100644 --- a/lib/core/motion/display_refresh_service.dart +++ b/lib/core/motion/display_refresh_service.dart @@ -25,7 +25,9 @@ abstract final class DisplayRefreshService { if (!kDebugMode) return; - _logRefreshInfo(); + // 2.x fills `info` asynchronously: read it once it had time to arrive, not + // at startup, where it always said 0 Hz. + unawaited(Future.delayed(const Duration(seconds: 2), _logRefreshInfo)); if (displayRefreshOverlayEnabled( debugMode: kDebugMode, overlayFlag: _overlayFromEnvironment, @@ -35,8 +37,11 @@ abstract final class DisplayRefreshService { } static void _logRefreshInfo() { - // The first reading can still be 0 Hz: 2.x fills `info` asynchronously. final info = RefreshRate.info; + if (info.currentRate <= 0) { + debugPrint('Display refresh: not reported by the platform'); + return; + } debugPrint( 'Display refresh: ${info.currentRate} Hz ' '(max ${info.maxRate}, variable=${info.isVariableRefreshRate})', diff --git a/lib/core/theme/parser/querya_editor_theme_from_manifest.dart b/lib/core/theme/parser/querya_editor_theme_from_manifest.dart index c91e13c0..3bca317c 100644 --- a/lib/core/theme/parser/querya_editor_theme_from_manifest.dart +++ b/lib/core/theme/parser/querya_editor_theme_from_manifest.dart @@ -4,8 +4,11 @@ import 'package:flutter/foundation.dart'; import '../querya_editor_theme.dart'; import 'color_parser.dart'; +import 'querya_workbench_theme_from_manifest.dart' show knownWorkbenchColorKeys; -const _knownEditorColorKeys = { +/// Keys of `editor_colors` that set the editor theme (the workbench keys of +/// the same map are read by `workbenchThemeFromQueryaColors`). +const knownEditorColorKeys = { 'background', 'foreground', 'lineHighlight', @@ -32,8 +35,9 @@ QueryaEditorTheme editorThemeFromQueryaColors({ }) { if (kDebugMode) { for (final key in colors.keys) { - if (!_knownEditorColorKeys.contains(key)) { - debugPrint('Querya theme: ignored editor_colors key "$key"'); + if (!knownEditorColorKeys.contains(key) && + !knownWorkbenchColorKeys.contains(key)) { + debugPrint('Querya theme: unknown editor_colors key "$key"'); } } } diff --git a/lib/core/theme/parser/querya_workbench_theme_from_manifest.dart b/lib/core/theme/parser/querya_workbench_theme_from_manifest.dart index d1f99b92..f409fdfa 100644 --- a/lib/core/theme/parser/querya_workbench_theme_from_manifest.dart +++ b/lib/core/theme/parser/querya_workbench_theme_from_manifest.dart @@ -9,7 +9,9 @@ import 'color_parser.dart'; /// /// Editor syntax/surface keys are mapped separately by [editorThemeFromQueryaColors]. /// The generic `background` key is intentionally not mapped to canvas/editorBackground. -const _knownWorkbenchColorKeys = { +/// Keys of `editor_colors` that set the workbench (the editor keys of the same +/// map are read by `editorThemeFromQueryaColors`). +const knownWorkbenchColorKeys = { 'canvas', 'surface', 'sidebarBackground', @@ -32,13 +34,8 @@ QueryaWorkbenchTheme workbenchThemeFromQueryaColors({ required Map colors, required QueryaWorkbenchTheme fallback, }) { - if (kDebugMode) { - for (final key in colors.keys) { - if (!_knownWorkbenchColorKeys.contains(key)) { - debugPrint('Querya theme: ignored editor_colors workbench key "$key"'); - } - } - } + // Unknown keys are reported once, by editorThemeFromQueryaColors: the + // same map holds the editor and the workbench keys. Color pick(String key, Color defaultValue) { final raw = colors[key]; diff --git a/test/core/theme/parser/querya_editor_theme_from_manifest_test.dart b/test/core/theme/parser/querya_editor_theme_from_manifest_test.dart index ff11ffb3..ca5f9f75 100644 --- a/test/core/theme/parser/querya_editor_theme_from_manifest_test.dart +++ b/test/core/theme/parser/querya_editor_theme_from_manifest_test.dart @@ -1,9 +1,11 @@ import 'dart:io'; +import 'package:flutter/foundation.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:querya_desktop/core/theme/parser/color_parser.dart'; import 'package:querya_desktop/core/theme/parser/querya_editor_theme_from_manifest.dart'; import 'package:querya_desktop/core/theme/parser/querya_theme_manifest.dart'; +import 'package:querya_desktop/core/theme/parser/querya_workbench_theme_from_manifest.dart'; import 'package:querya_desktop/core/theme/querya_theme.dart'; void main() { @@ -58,4 +60,32 @@ void main() { expect(editor.keyword, fallback.keyword); }); }); + + test('only keys that neither parser reads are reported', () { + final printed = []; + final original = debugPrint; + debugPrint = (message, {wrapWidth}) => printed.add(message ?? ''); + addTearDown(() => debugPrint = original); + + editorThemeFromQueryaColors( + colors: const { + 'background': '#000000', + 'canvas': '#111111', + 'sidebarBackground': '#222222', + 'accent': '#333333', + 'nonsense': '#444444', + }, + fallback: QueryaTheme.darkDefault.editor, + ); + workbenchThemeFromQueryaColors( + colors: const { + 'background': '#000000', + 'canvas': '#111111', + 'nonsense': '#444444', + }, + fallback: QueryaTheme.darkDefault.workbench, + ); + + expect(printed, ['Querya theme: unknown editor_colors key "nonsense"']); + }); }