From e05ffb075238d0264aa2bd4b9eb181b521b6b2d0 Mon Sep 17 00:00:00 2001 From: Nakul Date: Thu, 6 Nov 2025 16:30:53 +0530 Subject: [PATCH] Makeing right pane editable and update source on changes --- src/diff/cell.ts | 12 ++++++++++-- src/widget.ts | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/diff/cell.ts b/src/diff/cell.ts index fdbf1eb..a3e2b07 100644 --- a/src/diff/cell.ts +++ b/src/diff/cell.ts @@ -60,8 +60,16 @@ class CodeMirrorSplitDiffWidget extends BaseDiffWidget { extensions: [ basicSetup, python(), - EditorView.editable.of(false), - jupyterTheme + EditorView.editable.of(true), + jupyterTheme, + EditorView.updateListener.of(update => { + if (update.docChanged) { + const newText = update.state.doc.toString(); + + this._modifiedCode = newText; + this._newSource = newText; + } + }) ] }, parent: this.node diff --git a/src/widget.ts b/src/widget.ts index e37ef67..a744f16 100644 --- a/src/widget.ts +++ b/src/widget.ts @@ -100,7 +100,7 @@ export abstract class BaseDiffWidget extends Widget { */ public onAcceptClick(): void { if (this._cell) { - this._cell.sharedModel.setSource(this._newSource); + this._cell.sharedModel.setSource(this._newSource || this._originalSource); this._closeDiffView(); } } @@ -191,9 +191,9 @@ export abstract class BaseDiffWidget extends Widget { private _cell: ICellModel; private _cellFooterTracker: ICellFooterTracker; private _originalSource: string; - private _newSource: string; private _showActionButtons: boolean; private _openDiff: boolean; private _toggleButton: ToolbarButton | null = null; private _trans: TranslationBundle; + public _newSource: string; }