Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix createOutputs, rename 'modeldb' origin to 'silent-change' #254

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions javascript/src/ycell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ export class YBaseCell<Metadata extends nbformat.IBaseCellMetadata>
events: Y.YEvent<any>[],
transaction: Y.Transaction
) => {
if (transaction.origin !== 'modeldb') {
if (transaction.origin !== 'silent-change') {
this._changed.emit(this.getChanges(events));
}
};
Expand Down Expand Up @@ -771,27 +771,28 @@ export class YCodeCell

createOutputs(outputs: Array<nbformat.IOutput>): Array<Y.Map<any>> {
const newOutputs: Array<Y.Map<any>> = [];
for (const output of outputs) {
let _newOutput: { [id: string]: any };
const newOutput = new Y.Map();
for (const output of JSONExt.deepCopy(outputs)) {
let _newOutput1: { [id: string]: any };
if (output.output_type === 'stream') {
// Set the text field as a Y.Text
const { text, ...outputWithoutText } = output;
_newOutput = outputWithoutText;
_newOutput1 = outputWithoutText;
const newText = new Y.Text();
let length = 0;
// text is a list of strings
for (const str of text as string[]) {
newText.insert(length, str);
length += str.length;
}
_newOutput['text'] = newText;
_newOutput1['text'] = newText;
} else {
_newOutput = output;
_newOutput1 = output;
}
for (const [key, value] of Object.entries(_newOutput)) {
newOutput.set(key, value);
const _newOutput2: [string, any][] = [];
for (const [key, value] of Object.entries(_newOutput1)) {
_newOutput2.push([key, value]);
}
const newOutput = new Y.Map(_newOutput2);
newOutputs.push(newOutput);
}
return newOutputs;
Expand Down
Loading