mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2025-12-27 11:44:09 -05:00
Patch highlighting color scheme setting bug (#4622)
This commit is contained in:
@@ -30,7 +30,7 @@ import {themes, Themes} from './themes';
|
||||
import {AppTheme, ColourScheme, ColourSchemeInfo} from './colour';
|
||||
import {Hub} from './hub';
|
||||
import {EventHub} from './event-hub';
|
||||
import {keys} from '../lib/common-utils';
|
||||
import {keys, isString} from '../lib/common-utils';
|
||||
import {assert, unwrapString} from './assert';
|
||||
|
||||
import {LanguageKey} from '../types/languages.interfaces';
|
||||
@@ -459,12 +459,16 @@ export class Settings {
|
||||
const themeSelect = this.root.find('.theme');
|
||||
const colourSchemeSelect = this.root.find('.colourScheme');
|
||||
|
||||
if (!colourSchemeSelect.val()) {
|
||||
return;
|
||||
}
|
||||
const oldScheme = unwrapString(colourSchemeSelect.val());
|
||||
const oldScheme = colourSchemeSelect.val();
|
||||
const newTheme = unwrapString<colour.AppTheme>(themeSelect.val());
|
||||
|
||||
// Small check to make sure we aren't getting something completely unexpected, like a string[] or number
|
||||
assert(
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
isString(oldScheme) || oldScheme === undefined || oldScheme == null,
|
||||
'Unexpected value received from colourSchemeSelect.val()'
|
||||
);
|
||||
|
||||
this.fillColourSchemeSelector(colourSchemeSelect, newTheme);
|
||||
const newThemeStoredScheme = $.data(themeSelect, 'theme-' + newTheme) as colour.AppTheme | undefined;
|
||||
|
||||
@@ -473,7 +477,7 @@ export class Settings {
|
||||
// If we have one old one stored, check if it's still valid and set it if so
|
||||
if (newThemeStoredScheme && this.selectorHasOption(colourSchemeSelect, newThemeStoredScheme)) {
|
||||
newScheme = newThemeStoredScheme;
|
||||
} else if (this.selectorHasOption(colourSchemeSelect, oldScheme)) {
|
||||
} else if (isString(oldScheme) && this.selectorHasOption(colourSchemeSelect, oldScheme)) {
|
||||
newScheme = oldScheme;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user