Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix: only bold on selection (#4674)

Myles Scolnick1b4e586a1851
diff --git a/frontend/src/core/codemirror/markdown/__tests__/commands.test.ts b/frontend/src/core/codemirror/markdown/__tests__/commands.test.ts
index bb1d554b4b..09f03c3fd4 100644
--- a/frontend/src/core/codemirror/markdown/__tests__/commands.test.ts
+++ b/frontend/src/core/codemirror/markdown/__tests__/commands.test.ts
@@ -374,7 +374,7 @@ describe("insertTextFile", () => {
});
describe("insertBoldMarker", () => {
- test("inserts bold marker at cursor position", () => {
+ test("do not insert bold marker at cursor position", () => {
view = createEditor("Hello, world!");
view.dispatch({
selection: { anchor: 7, head: 7 },
@@ -382,7 +382,7 @@ describe("insertBoldMarker", () => {
insertBoldMarker(view);
- expect(view.state.doc.toString()).toBe("Hello, **world**!");
+ expect(view.state.doc.toString()).toBe("Hello, world!");
});
test("inserts bold marker at cursor position with selected text", () => {
diff --git a/frontend/src/core/codemirror/markdown/commands.ts b/frontend/src/core/codemirror/markdown/commands.ts
index a15f8e7707..17dd04f927 100644
--- a/frontend/src/core/codemirror/markdown/commands.ts
+++ b/frontend/src/core/codemirror/markdown/commands.ts
@@ -146,7 +146,10 @@ export function insertBlockquote(view: EditorView) {
}
export function insertBoldMarker(view: EditorView) {
- // Apply with or without selection
+ // Only apply on selection
+ if (!hasSelection(view)) {
+ return false;
+ }
const changes = view.state.changeByRange((range) => {
if (range.empty) {