Skip to content

Commit

Permalink
editorvm: fix #58
Browse files Browse the repository at this point in the history
  • Loading branch information
yatli committed Sep 15, 2019
1 parent 2e3d154 commit d31bbbb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
7 changes: 4 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
]
}
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"tasks": [
{
"label": "build",
"command": "dotnet build",
"command": "dotnet build -c Release",
"type": "shell",
"group": "build",
"presentation": {
Expand Down
8 changes: 7 additions & 1 deletion ViewModels/EditorViewModel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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)

Expand All @@ -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

Expand Down

0 comments on commit d31bbbb

Please sign in to comment.