Skip to content

Commit d95d620

Browse files
fix collapse expand state (microsoft#7492)
1 parent 4f3d5d7 commit d95d620

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

‎news/2 Fixes/7445.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Initial collapse / expand state broken by native liveshare work / gather

‎src/client/datascience/gather/gather.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { CellSlice } from '@msrvida/python-program-analysis/lib/cellslice';
44
import { ExecutionLogSlicer } from '@msrvida/python-program-analysis/lib/log-slicer';
55

66
import { inject, injectable } from 'inversify';
7+
// tslint:disable-next-line: no-require-imports
8+
import cloneDeep = require('lodash/cloneDeep');
79
import { IApplicationShell, ICommandManager } from '../../common/application/types';
810
import { traceInfo } from '../../common/logger';
911
import { IConfigurationService, IDisposableRegistry } from '../../common/types';
@@ -52,15 +54,18 @@ export class GatherExecution implements IGatherExecution, INotebookExecutionLogg
5254
if (this.enabled) {
5355
// Don't log if vscCell.data.source is an empty string. Original Jupyter extension also does this.
5456
if (vscCell.data.source !== '') {
57+
// First make a copy of this cell, as we are going to modify it
58+
const cloneCell: IVscCell = cloneDeep(vscCell);
59+
5560
// Strip first line marker. We can't do this at JupyterServer.executeCodeObservable because it messes up hashing
5661
const cellMatcher = new CellMatcher(this.configService.getSettings().datascience);
57-
vscCell.data.source = cellMatcher.stripFirstMarker(concatMultilineString(vscCell.data.source));
62+
cloneCell.data.source = cellMatcher.stripFirstMarker(concatMultilineString(vscCell.data.source));
5863

5964
// Convert IVscCell to IGatherCell
60-
const cell = convertVscToGatherCell(vscCell) as LabCell;
65+
const cell = convertVscToGatherCell(cloneCell) as LabCell;
6166

6267
// Call internal logging method
63-
if (!vscCell.data.source.startsWith(internalUseCellKey)) {
68+
if (!cloneCell.data.source.startsWith(internalUseCellKey)) {
6469
this._executionSlicer.logExecution(cell);
6570
}
6671
}

‎src/datascience-ui/interactive-common/mainStateController.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import * as uuid from 'uuid/v4';
1010

1111
import { createDeferred, Deferred } from '../../client/common/utils/async';
1212
import { CellMatcher } from '../../client/datascience/cellMatcher';
13-
import { generateMarkdownFromCodeLines } from '../../client/datascience/common';
13+
import { concatMultilineString, generateMarkdownFromCodeLines } from '../../client/datascience/common';
1414
import { Identifiers } from '../../client/datascience/constants';
1515
import {
1616
IInteractiveWindowMapping,
@@ -949,7 +949,7 @@ export class MainStateController implements IMessageHandler {
949949
newVMs[index] = cloneDeep(newVMs[index]);
950950

951951
// Check to see if our code still matches for the cell (in liveshare it might be updated from the other side)
952-
if (newVMs[index].cell.data.source !== cell.data.source) {
952+
if (concatMultilineString(newVMs[index].cell.data.source) !== concatMultilineString(cell.data.source)) {
953953
const newText = extractInputText(cell, getSettings());
954954
newVMs[index].inputBlockText = newText;
955955
}

0 commit comments

Comments
 (0)