Skip to content

Commit

Permalink
Fix soft-lock on document updates (#39)
Browse files Browse the repository at this point in the history
This PR fixes a minor oopsie that caused the language server to
unrecoverably hang whenever text was typed into the body of a WGSL
function.
  • Loading branch information
dannymcgee authored May 24, 2024
1 parent eeb31f0 commit d1c1c37
Show file tree
Hide file tree
Showing 30 changed files with 473 additions and 78 deletions.
158 changes: 158 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[workspace]
resolver = "2"
members = [
"packages/log",
"packages/parser",
"packages/server",
"packages/utils",
Expand All @@ -9,6 +10,12 @@ members = [

[workspace.dependencies]
anyhow = "1.0"
bevy_app = "0.13.2"
bevy_core = "0.13.2"
bevy_derive = "0.13.2"
bevy_log = "0.13.2"
bevy_ecs = "0.13.2"
bevy_utils = "0.13.2"
bitflags = "2.5"
gramatika = { version = "0.6.0", features = ["substr-source"] }
parking_lot = "0.12"
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@swc/helpers": "~0.5.2",
"@types/jest": "29.4.4",
"@types/node": "18.16.9",
"@types/vscode": "^1.61.0",
"@types/vscode": "^1.75.0",
"@typescript-eslint/eslint-plugin": "7.3.0",
"@typescript-eslint/parser": "7.3.0",
"@vscode-devkit/grammar": "0.0.1",
Expand Down
34 changes: 29 additions & 5 deletions packages/client/src/app/context.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ExtensionContext, OutputChannel, window } from "vscode";
import { ExtensionContext, LogOutputChannel, window } from "vscode";
import { LanguageClient } from "vscode-languageclient/node";

// prettier-ignore
Expand All @@ -8,12 +8,12 @@ class Context implements ExtensionContext {
inner: ExtensionContext;
client: LanguageClient;

private _channel: OutputChannel;
private _channel: LogOutputChannel;

constructor(ctx: ExtensionContext, client: LanguageClient) {
this.inner = ctx;
this.client = client;
this._channel = window.createOutputChannel("WGSL Language Client");
this._channel = window.createOutputChannel("WGSL Language Client", { log: true });

Context.instance = this;
}
Expand All @@ -39,8 +39,32 @@ class Context implements ExtensionContext {

get asAbsolutePath() { return this.inner.asAbsolutePath }

log(message: string): void {
this._channel.appendLine(message);
append(value: string): void {
this._channel.append(value);
}

appendLine(value: string): void {
this._channel.appendLine(value);
}

trace(message: string, ...args: any[]): void {
this._channel.trace(message, ...args);
}

debug(message: string, ...args: any[]): void {
this._channel.debug(message, ...args);
}

info(message: string, ...args: any[]): void {
this._channel.info(message, ...args);
}

warn(message: string, ...args: any[]): void {
this._channel.warn(message, ...args);
}

error(error: string | Error, ...args: any[]): void {
this._channel.error(error, ...args);
}
}

Expand Down
2 changes: 0 additions & 2 deletions packages/client/src/app/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import contentProviders, {

// prettier-ignore
export function activate(context: ExtensionContext) {
console.log("WGSL Language Support activated");

ctx.bootstrap(context, client.create());

contentProviders.register("wgsl-ast", DebugAstProvider);
Expand Down
20 changes: 20 additions & 0 deletions packages/log/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "wgsl-lsp-log"
version = "0.1.0"
edition = "2021"
license = "MIT OR Apache-2.0"

[dependencies]
bevy_app = { workspace = true }
bevy_ecs = { workspace = true }
bevy_utils = { workspace = true }
time = { version = "0.3.36", features = ["formatting", "local-offset", "macros"]}
tracing-error = "0.2.0"
tracing-log = "0.2.0"
tracing-subscriber = { version = "0.3.1", features = [
"env-filter",
"fmt",
"registry",
"std",
"time",
]}
Loading

0 comments on commit d1c1c37

Please sign in to comment.