Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f55c334

Browse files
joyceerhlrchiodo
authored andcommitted
Running an empty cell should not put an empty cell into the int… (microsoft#6844)
* Do not execute or render empty code cells submitted from editor * Do not execute or render empty cells submitted from the input box * Add news entry * Code hygiene * Use cellMatcher
1 parent c513de7 commit f55c334

File tree

4 files changed

+89
-76
lines changed

4 files changed

+89
-76
lines changed

news/2 Fixes/6839.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Do not execute empty code cells or render them in the interactive window when sent from the editor or input box

src/client/datascience/interactive-window/interactiveWindow.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ import {
7575
ISubmitNewCell,
7676
SysInfoReason
7777
} from './interactiveWindowTypes';
78+
import { CellMatcher } from '../cellMatcher';
7879

7980
@injectable()
8081
export class InteractiveWindow extends WebViewHost<IInteractiveWindowMapping> implements IInteractiveWindow {
@@ -744,8 +745,15 @@ export class InteractiveWindow extends WebViewHost<IInteractiveWindowMapping> im
744745
}
745746

746747
private async submitCode(code: string, file: string, line: number, id?: string, _editor?: TextEditor, debug?: boolean): Promise<boolean> {
747-
traceInfo(`Submitting code for ${this.id}`);
748748
let result = true;
749+
750+
// Do not execute or render empty code cells
751+
const cellMatcher = new CellMatcher(this.configService.getSettings().datascience);
752+
if (cellMatcher.stripFirstMarker(code).length === 0) {
753+
return result;
754+
}
755+
756+
traceInfo(`Submitting code for ${this.id}`);
749757
// Start a status item
750758
const status = this.setStatus(localize.DataScience.executingCode());
751759

src/client/datascience/webViewHost.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class WebViewHost<IMapping> implements IDisposable {
2929
private startupStopwatch = new StopWatch();
3030

3131
constructor(
32-
@unmanaged() private configService: IConfigurationService,
32+
@unmanaged() protected configService: IConfigurationService,
3333
@unmanaged() private provider: IWebPanelProvider,
3434
@unmanaged() private cssGenerator: ICodeCssGenerator,
3535
@unmanaged() protected themeFinder: IThemeFinder,

0 commit comments

Comments
 (0)