From b42cf8e20f29ec8f694773984868935f05e604b5 Mon Sep 17 00:00:00 2001 From: Pascal Garber Date: Thu, 11 Jun 2026 18:20:32 +0200 Subject: [PATCH 1/2] Gnome: highlight cursor line only while editing highlight_current_line was enabled unconditionally, so read-only tutorial code blocks showed their last line highlighted like a selection (the idle cursor sits at the buffer end). Tie the highlight to the editable state instead. Fixes #130 --- packages/app-gnome/src/widgets/source-view.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/app-gnome/src/widgets/source-view.ts b/packages/app-gnome/src/widgets/source-view.ts index 5f75ab68..565adcc1 100644 --- a/packages/app-gnome/src/widgets/source-view.ts +++ b/packages/app-gnome/src/widgets/source-view.ts @@ -262,6 +262,7 @@ export class SourceView extends Adw.Bin implements SourceViewWidget { */ public set editable(value: boolean) { this._sourceView.set_editable(value); + this.updateCurrentLineHighlight(); } /** @@ -315,7 +316,7 @@ export class SourceView extends Adw.Bin implements SourceViewWidget { this.copyClipboardSignalId = undefined; } } - this._sourceView.highlight_current_line = true; + this.updateCurrentLineHighlight(); } /** @@ -800,6 +801,14 @@ export class SourceView extends Adw.Bin implements SourceViewWidget { this.events.dispatch("changed", { code: this.code }); } + /** + * Highlight the cursor line only while editing: in read-only code blocks + * the idle cursor (sitting at the last line) would look like a selection. + */ + private updateCurrentLineHighlight() { + this._sourceView.highlight_current_line = this._sourceView.editable; + } + /** * Update the style of the source view. * Used internally to update the style of the source view when the theme changes. @@ -812,7 +821,7 @@ export class SourceView extends Adw.Bin implements SourceViewWidget { scheme = this.schemeManager.get_scheme(isDark ? "Adwaita-dark" : "Adwaita"); } if (scheme) this.buffer.set_style_scheme(scheme); - this._sourceView.set_highlight_current_line(true); + this.updateCurrentLineHighlight(); } /** From 7a0535b1869ddc6779ed96dbb27d19b152d19d07 Mon Sep 17 00:00:00 2001 From: Pascal Garber Date: Thu, 11 Jun 2026 18:46:03 +0200 Subject: [PATCH 2/2] Learn: render MDX code blocks read-only by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only blocks explicitly marked :readonly in the MDX were rendered read-only; the :copyable example blocks were silently editable, so the cursor-line fix did not apply to them and their last line still looked selected. MDX code blocks are documentation — the only editable SourceView is the editor itself. --- packages/learn/tsx/components/gtk/gtk-code.compontent.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/learn/tsx/components/gtk/gtk-code.compontent.tsx b/packages/learn/tsx/components/gtk/gtk-code.compontent.tsx index d6c8ede4..c734c960 100644 --- a/packages/learn/tsx/components/gtk/gtk-code.compontent.tsx +++ b/packages/learn/tsx/components/gtk/gtk-code.compontent.tsx @@ -160,7 +160,9 @@ export class GtkCode extends GtkWidget { */ protected parseAttributes(props: GtkCodeProps): Partial { let language = props.language || ""; - let readonly = props.readonly || false; + // MDX code blocks are documentation, so they always render read-only; + // the only editable SourceView is the editor itself + let readonly = props.readonly ?? true; let copyable = props.copyable || false; let unselectable = props.unselectable || false; let noLineNumbers = props.noLineNumbers || false;