Skip to content

Commit

Permalink
Merge pull request #175 from Techatrix/fix-diagnostics
Browse files Browse the repository at this point in the history
fix broken diagnostics
  • Loading branch information
Vexu authored Feb 14, 2024
2 parents 4c9a6fd + 77b7690 commit c423f51
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 84 deletions.
4 changes: 0 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"use strict";
import * as vscode from "vscode";
import { zigBuild } from "./zigBuild";
import ZigCompilerProvider from "./zigCompilerProvider";
import { ZigFormatProvider, ZigRangeFormatProvider } from "./zigFormat";
import { setupZig } from "./zigSetup";
Expand Down Expand Up @@ -38,9 +37,6 @@ export function activate(context: vscode.ExtensionContext) {
buildDiagnosticCollection = vscode.languages.createDiagnosticCollection("zig");
context.subscriptions.push(buildDiagnosticCollection);

// Commands
context.subscriptions.push(vscode.commands.registerCommand("zig.build.workspace", () => zigBuild()));

activateZls(context)
});
}
Expand Down
77 changes: 0 additions & 77 deletions src/zigBuild.ts

This file was deleted.

10 changes: 7 additions & 3 deletions src/zigCompilerProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export default class ZigCompilerProvider implements vscode.CodeActionProvider {

vscode.workspace.onDidChangeTextDocument(this.maybeDoASTGenErrorCheck, this);
vscode.workspace.onDidChangeTextDocument(this.maybeDoBuildOnSave, this);

subscriptions.push(vscode.commands.registerCommand("zig.build.workspace", () => this.doCompile(vscode.window.activeTextEditor.document)));
}

maybeDoASTGenErrorCheck(change: vscode.TextDocumentChangeEvent) {
Expand Down Expand Up @@ -104,7 +106,7 @@ export default class ZigCompilerProvider implements vscode.CodeActionProvider {
: vscode.DiagnosticSeverity.Information;
const range = new vscode.Range(line, column, line, Infinity);

if (diagnostics[path] === null) {diagnostics[path] = [];}
if (!diagnostics[path]) {diagnostics[path] = [];}
diagnostics[path].push(new vscode.Diagnostic(range, message, severity));
}

Expand All @@ -118,6 +120,8 @@ export default class ZigCompilerProvider implements vscode.CodeActionProvider {
private _doCompile(textDocument: vscode.TextDocument) {
const config = vscode.workspace.getConfiguration("zig");

const zigPath = getZigPath();

const buildOption = config.get<string>("buildOption");
const processArg: string[] = [buildOption];
let workspaceFolder = vscode.workspace.getWorkspaceFolder(textDocument.uri);
Expand Down Expand Up @@ -150,7 +154,7 @@ export default class ZigCompilerProvider implements vscode.CodeActionProvider {
});

let decoded = "";
const childProcess = cp.spawn("zig", processArg, { cwd });
const childProcess = cp.spawn(zigPath, processArg, { cwd });
if (childProcess.pid) {
childProcess.stderr.on("data", (data: Buffer) => {
decoded += data;
Expand Down Expand Up @@ -198,7 +202,7 @@ export default class ZigCompilerProvider implements vscode.CodeActionProvider {
: vscode.DiagnosticSeverity.Information;
const range = new vscode.Range(line, column, line, Infinity);

if (diagnostics[path] === null) {diagnostics[path] = [];}
if (!diagnostics[path]) {diagnostics[path] = [];}
diagnostics[path].push(
new vscode.Diagnostic(range, message, severity)
);
Expand Down

0 comments on commit c423f51

Please sign in to comment.