Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with dublication of the output channel #42

Merged
merged 1 commit into from
Oct 2, 2024
Merged
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
10 changes: 8 additions & 2 deletions src/coqLsp/coqLspClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Mutex } from "async-mutex";
import { readFileSync } from "fs";
import { OutputChannel } from "vscode";
import {
BaseLanguageClient,
Diagnostic,
Expand Down Expand Up @@ -76,9 +77,14 @@ export class CoqLspClient implements CoqLspClientInterface {

static async create(
serverConfig: CoqLspServerConfig,
clientConfig: CoqLspClientConfig
clientConfig: CoqLspClientConfig,
logOutputChannel: OutputChannel
): Promise<CoqLspClient> {
const connector = new CoqLspConnector(serverConfig, clientConfig);
const connector = new CoqLspConnector(
serverConfig,
clientConfig,
logOutputChannel
);
await connector.start().catch((error) => {
throw new CoqLspStartupError(
`failed to start coq-lsp with Error: ${error.message}`,
Expand Down
6 changes: 4 additions & 2 deletions src/coqLsp/coqLspConnector.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Uri } from "vscode";
import { OutputChannel, Uri } from "vscode";
import {
LanguageClientOptions,
RevealOutputChannelOn,
Expand All @@ -14,14 +14,16 @@ export class CoqLspConnector extends LanguageClient {
constructor(
serverConfig: CoqLspServerConfig,
clientConfig: CoqLspClientConfig,
public logOutputChannel: OutputChannel,
private eventLogger?: EventLogger
) {
let clientOptions: LanguageClientOptions = {
documentSelector: [
{ scheme: "file", language: "coq" },
{ scheme: "file", language: "markdown", pattern: "**/*.mv" },
],
outputChannelName: "CoqPilot: coq-lsp events",
outputChannel: logOutputChannel,
// outputChannelName: "CoqPilot: coq-lsp events",
revealOutputChannelOn: RevealOutputChannelOn.Info,
initializationOptions: serverConfig,
markdown: { isTrusted: true, supportHtml: true },
Expand Down
3 changes: 2 additions & 1 deletion src/extension/coqPilot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ export class CoqPilot {
CoqLspConfig.createClientConfig(coqLspServerPath);
const client = await CoqLspClient.create(
coqLspServerConfig,
coqLspClientConfig
coqLspClientConfig,
this.globalExtensionState.logOutputChannel
);
const contextTheoremsRanker = buildTheoremsRankerFromConfig();

Expand Down
6 changes: 5 additions & 1 deletion src/extension/globalExtensionState.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as fs from "fs";
import * as path from "path";
import * as tmp from "tmp";
import { WorkspaceConfiguration, workspace } from "vscode";
import { WorkspaceConfiguration, window, workspace } from "vscode";

import { LLMServices, disposeServices } from "../llm/llmServices";
import { GrazieService } from "../llm/llmServices/grazie/grazieService";
Expand All @@ -20,6 +20,9 @@ export class GlobalExtensionState {
this.eventLogger,
this.parseLoggingVerbosity(workspace.getConfiguration(pluginId))
);
public readonly logOutputChannel = window.createOutputChannel(
"CoqPilot: coq-lsp events"
);

public readonly llmServicesLogsDir = path.join(
tmp.dirSync().name,
Expand Down Expand Up @@ -65,5 +68,6 @@ export class GlobalExtensionState {
disposeServices(this.llmServices);
this.logWriter.dispose();
fs.rmSync(this.llmServicesLogsDir, { recursive: true, force: true });
this.logOutputChannel.dispose();
}
}
11 changes: 10 additions & 1 deletion src/test/benchmark/benchmarkingFramework.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as assert from "assert";
import * as fs from "fs";
import { window } from "vscode";

import { LLMServices } from "../../llm/llmServices";
import { GrazieService } from "../../llm/llmServices/grazie/grazieService";
Expand Down Expand Up @@ -425,7 +426,15 @@ async function createCoqLspClient(
process.env.COQ_LSP_PATH || "coq-lsp",
workspaceRootPath
);
return await CoqLspClient.create(coqLspServerConfig, coqLspClientConfig);
const logOutputChannel = window.createOutputChannel(
"CoqPilot: coq-lsp events"
);

return await CoqLspClient.create(
coqLspServerConfig,
coqLspClientConfig,
logOutputChannel
);
}

async function extractCompletionTargets(
Expand Down
11 changes: 10 additions & 1 deletion src/test/commonTestFunctions/coqLspBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { window } from "vscode";

import { CoqLspClient } from "../../coqLsp/coqLspClient";
import { CoqLspConfig } from "../../coqLsp/coqLspConfig";

Expand All @@ -9,6 +11,13 @@ export async function createCoqLspClient(
process.env.COQ_LSP_PATH || "coq-lsp",
workspaceRootPath
);
const logOutputChannel = window.createOutputChannel(
"CoqPilot: coq-lsp events"
);

return await CoqLspClient.create(coqLspServerConfig, coqLspClientConfig);
return await CoqLspClient.create(
coqLspServerConfig,
coqLspClientConfig,
logOutputChannel
);
}
Loading