From f38c15da9c764d655fae26d42d13903989b10328 Mon Sep 17 00:00:00 2001 From: Devin Bidwell Date: Sun, 7 Dec 2025 23:00:45 -0700 Subject: [PATCH] Remove references to Unitask and Cysharp --- Changelog.md | 5 +++++ ModData/About/About.xml | 4 ++-- csharp_mod/Formatter.cs | 34 ++++++++++++++++-------------- csharp_mod/stationeersSlang.csproj | 6 +----- rust_compiler/Cargo.lock | 2 +- rust_compiler/Cargo.toml | 2 +- 6 files changed, 28 insertions(+), 25 deletions(-) create mode 100644 Changelog.md diff --git a/Changelog.md b/Changelog.md new file mode 100644 index 0000000..f039671 --- /dev/null +++ b/Changelog.md @@ -0,0 +1,5 @@ +# Changelog + +[0.1.2] + +- Removed references to `Unitask` diff --git a/ModData/About/About.xml b/ModData/About/About.xml index d2b4897..b4f7c83 100644 --- a/ModData/About/About.xml +++ b/ModData/About/About.xml @@ -1,8 +1,8 @@ - StationeersSlang + Slang JoeDiertay - 0.1.1 + 0.1.2 [h1]Slang: High-Level Programming for Stationeers[/h1] diff --git a/csharp_mod/Formatter.cs b/csharp_mod/Formatter.cs index 24d0152..9ed20dd 100644 --- a/csharp_mod/Formatter.cs +++ b/csharp_mod/Formatter.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading; -using Cysharp.Threading.Tasks; +using System.Threading.Tasks; using StationeersIC10Editor; public class SlangFormatter : ICodeFormatter @@ -98,29 +98,32 @@ public class SlangFormatter : ICodeFormatter inputSrc = this.RawText; } - HandleLsp(inputSrc, token).Forget(); + _ = HandleLsp(inputSrc, token); } - private async UniTaskVoid HandleLsp(string inputSrc, CancellationToken cancellationToken) + private async Task HandleLsp(string inputSrc, CancellationToken cancellationToken) { try { - await UniTask.SwitchToThreadPool(); + if (cancellationToken.IsCancellationRequested) + return; + + await Task.Delay(200, cancellationToken: cancellationToken); if (cancellationToken.IsCancellationRequested) return; - await System.Threading.Tasks.Task.Delay(200, cancellationToken: cancellationToken); - - if (cancellationToken.IsCancellationRequested) - return; - - var dict = Marshal - .DiagnoseSource(inputSrc) - .GroupBy(d => d.Range.StartLine) - .ToDictionary(g => g.Key); - - await UniTask.Yield(PlayerLoopTiming.Update, cancellationToken); + // Running this potentially CPU intensive work on a background thread. + var dict = await Task.Run( + () => + { + return Marshal + .DiagnoseSource(inputSrc) + .GroupBy(d => d.Range.StartLine) + .ToDictionary(g => g.Key); + }, + cancellationToken + ); ApplyDiagnostics(dict); } @@ -136,7 +139,6 @@ public class SlangFormatter : ICodeFormatter { HashSet linesToRefresh; - // CRITICAL FIX FOR LINE SHIFTS: // If the line count has changed (lines added/deleted), indices have shifted. // We must refresh ALL lines to ensure any line that shifted into a new position // gets scrubbed of its old visual state. diff --git a/csharp_mod/stationeersSlang.csproj b/csharp_mod/stationeersSlang.csproj index a86c204..eda308a 100644 --- a/csharp_mod/stationeersSlang.csproj +++ b/csharp_mod/stationeersSlang.csproj @@ -5,7 +5,7 @@ enable StationeersSlang Slang Compiler Bridge - 0.1.1 + 0.1.2 true latest @@ -39,10 +39,6 @@ ./ref/Assembly-CSharp.dll False - - ./ref/UniTask.dll - False - ./ref/IC10Editor.dll diff --git a/rust_compiler/Cargo.lock b/rust_compiler/Cargo.lock index 5b620a0..50bc630 100644 --- a/rust_compiler/Cargo.lock +++ b/rust_compiler/Cargo.lock @@ -843,7 +843,7 @@ checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" [[package]] name = "slang" -version = "0.1.1" +version = "0.1.2" dependencies = [ "anyhow", "clap", diff --git a/rust_compiler/Cargo.toml b/rust_compiler/Cargo.toml index 6ac3e63..bac327e 100644 --- a/rust_compiler/Cargo.toml +++ b/rust_compiler/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "slang" -version = "0.1.1" +version = "0.1.2" edition = "2021" [workspace]