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

[code] Don't trigger goals buffer action in general Markdown documents #625

Merged
merged 1 commit into from
Nov 26, 2023
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
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
(@ejgallego, #616)
- completion: correctly understand UTF-16 code points on completion
request (Léo Stefanesco, #613, fixes #531)
- don't trigger the goals window in general markdown buffer
(@ejgallego, #625, reported by Théo Zimmerman)

# coq-lsp 0.1.8: Trick-or-treat
-------------------------------
Expand Down
14 changes: 9 additions & 5 deletions editor/code/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
ThemeColor,
WorkspaceConfiguration,
Disposable,
DocumentSelector,
languages,
} from "vscode";

import {
Expand All @@ -29,7 +31,11 @@ import {
GoalAnswer,
PpString,
} from "../lib/types";
import { CoqLspClientConfig, CoqLspServerConfig } from "./config";
import {
CoqLspClientConfig,
CoqLspServerConfig,
coqLSPDocumentSelector,
} from "./config";
import { InfoPanel, goalReq } from "./goals";
import { FileProgressManager } from "./progress";
import { coqPerfData, PerfDataView } from "./perf";
Expand Down Expand Up @@ -208,10 +214,8 @@ export function activateCoqLSP(
textEditor: TextEditor,
callKind: TextEditorSelectionChangeKind | undefined
) => {
if (
textEditor.document.languageId != "coq" &&
textEditor.document.languageId != "markdown"
)
// Don't trigger the goals if the buffer is not owned by us
if (languages.match(coqLSPDocumentSelector, textEditor.document) < 1)
return;

const kind =
Expand Down
6 changes: 5 additions & 1 deletion editor/code/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ExtensionContext, workspace } from "vscode";
import { DocumentSelector, ExtensionContext, workspace } from "vscode";

export interface CoqLspServerConfig {
client_version: string;
Expand Down Expand Up @@ -54,3 +54,7 @@ export namespace CoqLspClientConfig {
return obj;
}
}
export const coqLSPDocumentSelector: DocumentSelector = [
{ language: "coq" },
{ language: "markdown", pattern: "**/*.mv" },
];
14 changes: 9 additions & 5 deletions editor/code/src/progress.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { throttle } from "throttle-debounce";
import { Disposable, Range, window, OverviewRulerLane } from "vscode";
import {
Disposable,
Range,
window,
OverviewRulerLane,
languages,
} from "vscode";
import {
NotificationType,
VersionedTextDocumentIdentifier,
} from "vscode-languageclient";
import { BaseLanguageClient } from "vscode-languageclient";
import { coqLSPDocumentSelector } from "./config";

enum CoqFileProgressKind {
Processing = 1,
Expand Down Expand Up @@ -64,10 +71,7 @@ export class FileProgressManager {
});
private cleanDecos() {
for (const editor of window.visibleTextEditors) {
if (
editor.document.languageId === "coq" ||
editor.document.languageId === "markdown"
) {
if (languages.match(coqLSPDocumentSelector, editor.document) > 0) {
editor.setDecorations(progressDecoration, []);
}
}
Expand Down