Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/core/motion/display_refresh_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>.delayed(const Duration(seconds: 2), _logRefreshInfo));
if (displayRefreshOverlayEnabled(
debugMode: kDebugMode,
overlayFlag: _overlayFromEnvironment,
Expand All @@ -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})',
Expand Down
10 changes: 7 additions & 3 deletions lib/core/theme/parser/querya_editor_theme_from_manifest.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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"');
}
}
}
Expand Down
13 changes: 5 additions & 8 deletions lib/core/theme/parser/querya_workbench_theme_from_manifest.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -32,13 +34,8 @@ QueryaWorkbenchTheme workbenchThemeFromQueryaColors({
required Map<String, String> 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];
Expand Down
30 changes: 30 additions & 0 deletions test/core/theme/parser/querya_editor_theme_from_manifest_test.dart
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down Expand Up @@ -58,4 +60,32 @@ void main() {
expect(editor.keyword, fallback.keyword);
});
});

test('only keys that neither parser reads are reported', () {
final printed = <String>[];
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"']);
});
}
Loading