Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -381,3 +381,4 @@ onigwrap/src/onigwrap.lib
onigwrap/src/onigwrap.exp
onigwrap/src/onigwrap.dll
onigwrap/src/onig_s.lib
onigwrap/src/libonigwrap.wasm
Binary file not shown.
10 changes: 7 additions & 3 deletions src/TextMateSharp/Model/TMModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;

using TextMateSharp.Grammars;

Expand Down Expand Up @@ -38,6 +39,7 @@ class TokenizerThread
private string name;
private TMModel model;
private TMState lastState;
private Task task;

public TokenizerThread(string name, TMModel model)
{
Expand All @@ -50,15 +52,18 @@ public void Run()
{
IsStopped = false;

ThreadPool.QueueUserWorkItem(ThreadWorker);
task = Task.Run(ThreadWorker);
}

public void Stop()
{
IsStopped = true;
this.model._resetEvent.Set();
task?.Wait(TimeSpan.FromSeconds(1));
task?.Dispose();
}

void ThreadWorker(object state)
void ThreadWorker()
{
if (IsStopped)
{
Expand Down Expand Up @@ -336,7 +341,6 @@ private void Stop()
}

this._thread.Stop();
_resetEvent.Set();
this._thread = null;
}

Expand Down
12 changes: 12 additions & 0 deletions src/TextMateSharp/TextMateSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ TextMateSharp uses a wrapper around Oniguruma regex engine. Read below to learn
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<TargetPath>libonigwrap.dylib</TargetPath>
</ContentWithTargetPath>
<!-- native oniguruma library for web assembly -->
<ContentWithTargetPath Include="Internal\Oniguruma\Native\browser-wasm\libonigwrap.wasm">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<TargetPath>libonigwrap.wasm</TargetPath>
</ContentWithTargetPath>
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -64,6 +69,13 @@ TextMateSharp uses a wrapper around Oniguruma regex engine. Read below to learn
<Pack>true</Pack>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<!-- native oniguruma library for wasm in nuget package -->
<Content Include="Internal\Oniguruma\Native\browser-wasm\libonigwrap.wasm">
<Link>libonigwrap.wasm</Link>
<PackagePath>runtimes/browser-wasm/native/libonigwrap.wasm</PackagePath>
<Pack>true</Pack>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
Expand Down