Repository: veler/DevToys
File: src/app/dev/DevToys.Blazor/Components/Text/MonacoEditor/MonacoEditor.razor.cs (C#)

Code before:
        base.OnParametersSet();

        if (SettingsProvider is not null)
        {
            SettingsProvider_SettingChanged(SettingsProvider, null!);
        }
    }

    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if (firstRender)
        {
            InvokeAsync(DisplayLoadingIfSlowLoadingAsync).Forget();

            // Get desired options
            StandaloneEditorConstructionOptions options = ConstructionOptions?.Invoke(this) ?? new();

            // Overwrite some important options.
            options.Theme = GetTheme();
            options.ReadOnly = options.ReadOnly.GetValueOrDefault(false) || !IsActuallyEnabled;
            options.AutomaticLayout = true;
            options.GlyphMargin = false;
            options.MouseWheelZoom = false;
            options.OverviewRulerBorder = false;
            options.ScrollBeyondLastLine = false;
            options.FontLigatures = false;
            options.SnippetSuggestions = "none";
            options.CodeLens = false;
            options.QuickSuggestions = new QuickSuggestionsOptions { Comments = false, Other = false, Strings = false };
            options.WordBasedSuggestions = false;
            options.Minimap = new EditorMinimapOptions { Enabled = false };
            options.Hover = new EditorHoverOptions { Enabled = false };
            options.MatchBrackets = "always";
            options.BracketPairColorization = new BracketPairColorizationOptions { Enabled = true };
            options.RenderLineHighlightOnlyWhenFocus = true;

            // Apply global user settings
            options.FontFamily = SettingsProvider.GetSetting(PredefinedSettings.TextEditorFont);
            options.LineNumbers = SettingsProvider.GetSetting(PredefinedSettings.TextEditorLineNumbers) ? "on" : "off";
            options.RenderLineHighlight = SettingsProvider.GetSetting(PredefinedSettings.TextEditorHighlightCurrentLine) ? "all" : "none";
            options.RenderWhitespace = SettingsProvider.GetSetting(PredefinedSettings.TextEditorRenderWhitespace) ? "all" : "none";
            ApplyWordWrapOption(options);

            // Create the editor
            await MonacoEditorHelper.CreateMonacoEditorInstanceAsync(JSRuntime, Id, options, null, Reference);
        }

        if (IsActuallyEnabled != _oldIsActuallyEnabled && !_isDisposed)
        {
            _oldIsActuallyEnabled = IsActuallyEnabled;


Review comment (suggestion):
Unrelated change, but nice to have. It enabled font ligatures as it says. Depending on user feedback, we could consider adding an option in `Settings` to enable/disable ligatures.

Code after:
        base.OnParametersSet();

        if (SettingsProvider is not null)
        {
            SettingsProvider_SettingChanged(SettingsProvider, null!);
        }
    }

    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if (firstRender)
        {
            InvokeAsync(DisplayLoadingIfSlowLoadingAsync).Forget();

            // Get desired options
            StandaloneEditorConstructionOptions options = ConstructionOptions?.Invoke(this) ?? new();

            // Overwrite some important options.
            options.Theme = GetTheme();
            options.ReadOnly = options.ReadOnly.GetValueOrDefault(false) || !IsActuallyEnabled;
            options.AutomaticLayout = true;
            options.GlyphMargin = false;
            options.MouseWheelZoom = false;
            options.OverviewRulerBorder = false;
            options.ScrollBeyondLastLine = false;
            options.FontLigatures = true;
            options.SnippetSuggestions = "none";
            options.CodeLens = false;
            options.QuickSuggestions = new QuickSuggestionsOptions { Comments = false, Other = false, Strings = false };
            options.WordBasedSuggestions = false;
            options.Minimap = new EditorMinimapOptions { Enabled = false };
            options.Hover = new EditorHoverOptions { Enabled = true, Above = false };
            options.MatchBrackets = "always";
            options.BracketPairColorization = new BracketPairColorizationOptions { Enabled = true };
            options.RenderLineHighlightOnlyWhenFocus = true;

            // Apply global user settings
            options.FontFamily = SettingsProvider.GetSetting(PredefinedSettings.TextEditorFont);
            options.LineNumbers = SettingsProvider.GetSetting(PredefinedSettings.TextEditorLineNumbers) ? "on" : "off";
            options.RenderLineHighlight = SettingsProvider.GetSetting(PredefinedSettings.TextEditorHighlightCurrentLine) ? "all" : "none";
            options.RenderWhitespace = SettingsProvider.GetSetting(PredefinedSettings.TextEditorRenderWhitespace) ? "all" : "none";
            ApplyWordWrapOption(options);

            // Create the editor
            await MonacoEditorHelper.CreateMonacoEditorInstanceAsync(JSRuntime, Id, options, null, Reference);
        }

        if (IsActuallyEnabled != _oldIsActuallyEnabled && !_isDisposed)
        {
            _oldIsActuallyEnabled = IsActuallyEnabled;