Skip to content

Commit

Permalink
Fix a modification of the first caracter
Browse files Browse the repository at this point in the history
  • Loading branch information
brichet committed Dec 14, 2023
1 parent 286fe23 commit bb238a0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/cellfactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,15 @@ class CustomCodeCell extends CodeCell implements ICustomCodeCell {
*/
private _onSharedModelChanged = (_: ISharedCodeCell, change: CellChange) => {
if (this._kernelInjection.getStatus(this) && change.sourceChange) {
// Check if the change is in the first line
const firstLine = this.model.sharedModel.source.split('\n')[0];
const position = change.sourceChange.find(
change => change.retain !== undefined
)?.retain;

// If an object with the key 'retain' exists, it will give the position of the
// change. Otherwise we assume the change occurs at position 0;
const position =
change.sourceChange.find(change => change.retain !== undefined)
?.retain || 0;

// Check if the change occurs on the first line to update header and widgets.
if (position !== undefined && position <= firstLine.length) {
this._checkSource();
const databaseURL = MagicLine.getDatabaseUrl(this.model);
Expand Down

0 comments on commit bb238a0

Please sign in to comment.