From d31bbbbcc922e9a8217999bd63c8e1c111262a4a Mon Sep 17 00:00:00 2001 From: v-yadli Date: Sun, 15 Sep 2019 08:47:30 -0700 Subject: [PATCH] editorvm: fix #58 --- .vscode/launch.json | 7 ++++--- .vscode/tasks.json | 2 +- ViewModels/EditorViewModel.fs | 8 +++++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index b92c78d..d887356 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,11 +9,12 @@ "type": "coreclr", "request": "launch", "preLaunchTask": "build", - "program": "${workspaceFolder}/bin/Debug/netcoreapp2.1/fvim.dll", + "program": "${workspaceFolder}/bin/Release/netcoreapp3.0/fvim.dll", "args": [], - "cwd": "${workspaceFolder}/bin/Debug/netcoreapp2.1/", + "cwd": "${workspaceFolder}/bin/Release/netcoreapp3.0/", "stopAtEntry": false, - "console": "internalConsole" + "console": "internalConsole", + "justMyCode": false }, ] } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index a914fef..bfefeae 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -5,7 +5,7 @@ "tasks": [ { "label": "build", - "command": "dotnet build", + "command": "dotnet build -c Release", "type": "shell", "group": "build", "presentation": { diff --git a/ViewModels/EditorViewModel.fs b/ViewModels/EditorViewModel.fs index 083e418..a0b88be 100644 --- a/ViewModels/EditorViewModel.fs +++ b/ViewModels/EditorViewModel.fs @@ -21,6 +21,7 @@ open System.Collections.ObjectModel open Avalonia.Controls open System.Reactive.Disposables open SkiaSharp +open System.Runtime.InteropServices type EditorViewModel(GridId: int, ?parent: EditorViewModel, ?_gridsize: GridSize, ?_glyphsize: Size, ?_measuredsize: Size, ?_fontsize: float, ?_gridscale: float, ?_hldefs: HighlightAttr[], ?_modedefs: ModeInfo[], ?_guifont: string, ?_guifontwide: string, ?_cursormode: int, ?_anchorX: float, ?_anchorY: float) as this = @@ -417,6 +418,11 @@ type EditorViewModel(GridId: int, ?parent: EditorViewModel, ?_gridsize: GridSize m_default_fg <- fg m_default_sp <- sp fontConfig() + + let tick_throttle = + if RuntimeInformation.IsOSPlatform(OSPlatform.OSX) then id + else Observable.throttle(TimeSpan.FromMilliseconds 10.0) + this.Watch [ Model.Redraw (Array.iter redraw) @@ -431,7 +437,7 @@ type EditorViewModel(GridId: int, ?parent: EditorViewModel, ?_gridsize: GridSize |> Observable.subscribe markAllDirty m_tick_ev.Publish - |> Observable.throttle(TimeSpan.FromMilliseconds 10.0) + |> tick_throttle |> Observable.observeOn Avalonia.Threading.AvaloniaScheduler.Instance |> Observable.subscribe flush