Skip to content
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
1 change: 1 addition & 0 deletions apps/vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 1.140.0 (Unreleased)

- Fixed a bug where the language server could hang when hovering over text on a line that contains single-line display math such as `$$x$$` (<https://github.com/quarto-dev/quarto/pull/1212>).
- In the visual editor, the Insert Emoji and Insert Unicode popups no longer close on their own about five seconds after the editor is first focused, which could happen while a search term was still being typed. They now close when the editor is scrolled or focus moves elsewhere within the editor, as do the completion popups for citations, cross references and the `/` insert menu (<https://github.com/quarto-dev/quarto/pull/1204>).
- In the visual editor, the equation preview popup now follows its equation again after the window or editor pane is resized. Previously it stayed in place until the next edit or cursor move (<https://github.com/quarto-dev/quarto/pull/1204>).
- The outline no longer shows duplicate "Quarto" groups for a document after settings change quickly, for example while VS Code starts (<https://github.com/quarto-dev/quarto/pull/1210>).
Expand Down
2 changes: 1 addition & 1 deletion packages/quarto-core/src/markdown/cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function isLatexCodeBlock(token: Token) {
}

const kInlineMathPattern = /\$([^ ].*?[^ ]?)\$/g;
const kSingleLineDisplayMathPattern = /\$\$([^\n]+?)\$\$/;
const kSingleLineDisplayMathPattern = /\$\$([^\n]+?)\$\$/g;

function inlineMathRange(pos: Position, line: string, pattern: RegExp) {
pattern.lastIndex = 0;
Expand Down
61 changes: 61 additions & 0 deletions packages/quarto-core/test/cursor.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* cursor.test.ts
*
* Copyright (C) 2026 by Posit Software, PBC
*/

import assert from "node:assert/strict";
import test from "node:test";
import { runInNewContext } from "node:vm";

import { Position, Range } from "vscode-languageserver-types";

import { Document } from "../src/document";
import { mathRange } from "../src/markdown/cursor";
import { markdownitParser } from "../src/markdown/parsers/markdownit";

function document(text: string): Document {
return {
uri: "file:///math.qmd",
languageId: "quarto",
version: 1,
lineCount: 1,
getText: () => text,
positionAt: (offset) => Position.create(0, offset),
};
}

for (const [text, character] of [
["Before $$x$$ after", 0],
["Before $$x$$ after", 16],
["Before $$x$$ and $$y$$ after", 14],
["Before $$x$$ and $$y$$ after", 26],
] as const) {
test(`returns no math at character ${character} in ${JSON.stringify(text)}`, () => {
assert.equal(
runInNewContext(
"mathRange(parser, doc, position)",
{ mathRange, parser: markdownitParser(), doc: document(text), position: Position.create(0, character) },
{ timeout: 1000 }
),
null
);
});
}

test("finds later display math and resets the search for repeated requests", () => {
const parser = markdownitParser();
const doc = document("Before $$x$$ and $$y$$ after");
for (const character of [22, 12, 22, 12]) {
assert.deepEqual(
runInNewContext(
"mathRange(parser, doc, position)",
{ mathRange, parser, doc, position: Position.create(0, character) },
{ timeout: 1000 }
),
character === 22
? { math: "y", range: Range.create(0, 17, 0, 22) }
: { math: "x", range: Range.create(0, 7, 0, 12) }
);
}
});
Loading