@@ -4,6 +4,8 @@ import { CellSlice } from '@msrvida/python-program-analysis/lib/cellslice';
44import { ExecutionLogSlicer } from '@msrvida/python-program-analysis/lib/log-slicer' ;
55
66import { inject , injectable } from 'inversify' ;
7+ // tslint:disable-next-line: no-require-imports
8+ import cloneDeep = require( 'lodash/cloneDeep' ) ;
79import { IApplicationShell , ICommandManager } from '../../common/application/types' ;
810import { traceInfo } from '../../common/logger' ;
911import { 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 }
0 commit comments