Skip to content

Commit

Permalink
Fetch settings in initializeGlobalDependent (#4307)
Browse files Browse the repository at this point in the history
  • Loading branch information
RubenRBS committed Nov 25, 2022
1 parent ec44737 commit f1a4f16
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
5 changes: 2 additions & 3 deletions static/panes/compiler.ts
Expand Up @@ -39,7 +39,7 @@ import * as monacoConfig from '../monaco-config';
import * as TimingWidget from '../widgets/timing-info-widget';
import {CompilerPicker} from '../compiler-picker';
import {CompilerService} from '../compiler-service';
import {Settings, SiteSettings} from '../settings';
import {SiteSettings} from '../settings';
import * as LibUtils from '../lib-utils';
import {getAssemblyDocumentation} from '../api/api';
import {MonacoPane} from './pane';
Expand All @@ -48,7 +48,7 @@ import {MonacoPaneState} from './pane.interfaces';
import {Hub} from '../hub';
import {Container} from 'golden-layout';
import {CompilerState} from './compiler.interfaces';
import {ComponentConfig, GccDumpOptions, ToolViewState} from '../components.interfaces';
import {ComponentConfig, ToolViewState} from '../components.interfaces';
import {FiledataPair} from '../multifile-service';
import {LanguageLibs} from '../options.interfaces';
import {CompilerFilters} from '../../types/features/filters.interfaces';
Expand Down Expand Up @@ -320,7 +320,6 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
super(hub, container, state);

this.id = state.id || hub.nextCompilerId();
this.settings = Settings.getStoredSettings();

this.infoByLang = {};
this.deferCompiles = hub.deferred;
Expand Down
9 changes: 4 additions & 5 deletions static/panes/diff.ts
Expand Up @@ -260,7 +260,8 @@ export class Diff extends MonacoPane<monaco.editor.IStandaloneDiffEditor, DiffSt

override createEditor(editorRoot: HTMLElement) {
return monaco.editor.createDiffEditor(editorRoot, {
fontFamily: 'Consolas, "Liberation Mono", Courier, monospace',
fontFamily: this.settings.editorsFFont,
fontLigatures: this.settings.editorsFLigatures,
scrollBeyondLastLine: true,
readOnly: true,
});
Expand All @@ -272,7 +273,7 @@ export class Diff extends MonacoPane<monaco.editor.IStandaloneDiffEditor, DiffSt
this.updateState();
}

onCompileResult(id: number | string, compiler: CompilerInfo, result: CompilationResult) {
override onCompileResult(id: number | string, compiler: CompilerInfo, result: CompilationResult) {
// both sides must be updated, don't be tempted to rewrite this as
// var changes = lhs.update() || rhs.update();
const lhsChanged = this.lhs.update(id, compiler, result);
Expand Down Expand Up @@ -322,9 +323,7 @@ export class Diff extends MonacoPane<monaco.editor.IStandaloneDiffEditor, DiffSt
if (!compiler) return;
options = options || '';
let name = compiler.name + ' ' + options;
// TODO: selectize doesn't play nicely with CSS tricks for truncation; this is the best I can do
// There's a plugin at: http://www.benbybenjacobs.com/blog/2014/04/09/no-wrap-plugin-for-selectize-dot-js
// but it doesn't look easy to integrate.
// TODO: tomselect doesn't play nicely with CSS tricks for truncation; this is the best I can do
const maxLength = 30;
if (name.length > maxLength - 3) name = name.substr(0, maxLength - 3) + '...';
this.compilers[id] = {
Expand Down
3 changes: 1 addition & 2 deletions static/panes/editor.ts
Expand Up @@ -500,7 +500,6 @@ export class Editor extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Edit
super.initializeGlobalDependentProperties();

this.httpRoot = window.httpRoot;
this.settings = Settings.getStoredSettings();
this.langKeys = Object.keys(languages);
}

Expand Down Expand Up @@ -1207,7 +1206,7 @@ export class Editor extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Edit
}
}

override onSettingsChange(newSettings: SiteSettings | Record<string, never>): void {
override onSettingsChange(newSettings: SiteSettings): void {
const before = this.settings;
const after = newSettings;
this.settings = {...newSettings};
Expand Down
8 changes: 5 additions & 3 deletions static/panes/pane.ts
Expand Up @@ -29,7 +29,7 @@ import * as monaco from 'monaco-editor';
import {MonacoPaneState, PaneCompilerState, PaneState} from './pane.interfaces';

import {FontScale} from '../widgets/fontscale';
import {SiteSettings} from '../settings';
import {Settings, SiteSettings} from '../settings';
import * as utils from '../utils';

import {PaneRenaming} from '../widgets/pane-renaming';
Expand All @@ -50,7 +50,7 @@ export abstract class Pane<S> {
protected hub: Hub;
eventHub: EventHub;
isAwaitingInitialResults = false;
settings: SiteSettings | Record<string, never> = {};
settings: SiteSettings;
paneName: string | undefined = undefined;
paneRenaming: PaneRenaming;

Expand Down Expand Up @@ -119,7 +119,9 @@ export abstract class Pane<S> {

initializeDefaults(): void {}

initializeGlobalDependentProperties(): void {}
initializeGlobalDependentProperties(): void {
this.settings = Settings.getStoredSettings();
}

initializeStateDependentProperties(state: S): void {}

Expand Down
2 changes: 0 additions & 2 deletions static/panes/tool-input-view.ts
Expand Up @@ -45,8 +45,6 @@ export class ToolInputView extends MonacoPane<monaco.editor.IStandaloneCodeEdito
if ((state as any).compilerId) state.id = (state as any).compilerId;
super(hub, container, state);

this.settings = Settings.getStoredSettings();

this._toolId = state.toolId;
this._toolName = state.toolName;
// TODO according to TS typing this should always be true
Expand Down

0 comments on commit f1a4f16

Please sign in to comment.