Skip to content

Commit

Permalink
Merge pull request #625 from ejgallego/stricter_goals_focus
Browse files Browse the repository at this point in the history
[code] Don't trigger goals buffer action in general Markdown documents
  • Loading branch information
ejgallego authored Nov 26, 2023
2 parents 9a96682 + 5d9523b commit 75a92e0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
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

0 comments on commit 75a92e0

Please sign in to comment.