diff --git a/src/editors/automerge/livePreview/hrDecoration.ts b/src/editors/automerge/livePreview/hrDecoration.ts index dca4157..32633dd 100644 --- a/src/editors/automerge/livePreview/hrDecoration.ts +++ b/src/editors/automerge/livePreview/hrDecoration.ts @@ -37,10 +37,12 @@ export function buildHrDecorations( enter(node) { if (node.name !== 'HorizontalRule') return; const line = state.doc.lineAt(node.from); + // When the cursor is on the rule's line, show the raw `---` and draw + // no rule at all — so editing the line is unambiguous. Off the line, + // apply the line style and hide the glyphs so the rule alone shows. + if (line.number === cursorLine) return; decos.push({ from: line.from, to: line.from, deco: hrLine }); - // Hide the whole line's text (including any leading whitespace) so - // the border alone reads as the rule. - if (line.number !== cursorLine && line.to > line.from) { + if (line.to > line.from) { decos.push({ from: line.from, to: line.to, deco: hrLineHiddenMark }); } }, diff --git a/src/editors/automerge/livePreview/livePreview.test.ts b/src/editors/automerge/livePreview/livePreview.test.ts index 0cf45e2..643e651 100644 --- a/src/editors/automerge/livePreview/livePreview.test.ts +++ b/src/editors/automerge/livePreview/livePreview.test.ts @@ -251,6 +251,13 @@ describe('hrDecoration', () => { expect(hidden).toHaveLength(1); expect(hidden[0].text).toBe('---'); }); + + it('shows raw --- with no rule when the cursor is on the line', () => { + const state = makeState('para\n\n---\n\nmore', 7); // on the "---" line + const list = decos(state, buildHrDecorations(state)); + expect(withClass(list, 'cm-hr')).toHaveLength(0); + expect(withClass(list, 'cm-hr-line-hidden')).toHaveLength(0); + }); }); describe('listDecoration', () => {