Skip to content

Run by line changes for release #12256

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

Merged
merged 2 commits into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions news/1 Enhancements/12249.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make stop during run by line interrupt the kernel.
7 changes: 4 additions & 3 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -506,10 +506,11 @@
"StartPage.helloWorld": "Hello world",
"StartPage.sampleNotebook": "Welcome_To_VSCode_Notebooks.ipynb",
"DataScience.libraryRequiredToLaunchJupyterKernelNotInstalledInterpreter": "{0} requires {1} to be installed.",
"DataScience.runByLine": "Run by line",
"DataScience.continueRunByLine": "Stop",
"DataScience.runByLine": "Run by line (F10)",
"DataScience.stopRunByLine": "Stop",
"DataScience.couldNotInstallLibrary": "Could not install {0}. If pip is not available, please use the package manager of your choice to manually install this library into your Python environment.",
"DataScience.rawKernelSessionFailed": "Unable to start session for kernel {0}. Select another kernel to launch with.",
"DataScience.rawKernelConnectingSession": "Connecting to kernel.",
"DataScience.reloadCustomEditor": "Please reload VS Code to use the custom editor API"
"DataScience.reloadCustomEditor": "Please reload VS Code to use the custom editor API",
"DataScience.step": "Run next line (F10)"
}
5 changes: 3 additions & 2 deletions src/client/common/utils/localize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -937,8 +937,9 @@ export namespace DataScience {
);

export const kernelStarted = localize('DataScience.kernelStarted', 'Started kernel {0}.');
export const runByLine = localize('DataScience.runByLine', 'Run by line');
export const continueRunByLine = localize('DataScience.continueRunByLine', 'Stop');
export const runByLine = localize('DataScience.runByLine', 'Run by line (F10)');
export const step = localize('DataScience.step', 'Run next line (F10)');
export const stopRunByLine = localize('DataScience.stopRunByLine', 'Stop');
export const rawKernelSessionFailed = localize(
'DataScience.rawKernelSessionFailed',
'Unable to start session for kernel {0}. Select another kernel to launch with.'
Expand Down
31 changes: 21 additions & 10 deletions src/datascience-ui/native-editor/nativeCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ import { IMonacoModelContentChangeEvent } from '../react-common/monacoHelpers';
import { AddCellLine } from './addCellLine';
import { actionCreators } from './redux/actions';

import { CodIcon } from '../react-common/codicon/codicon';
import '../react-common/codicon/codicon.css';

namespace CssConstants {
export const CellOutputWrapper = 'cell-output-wrapper';
export const CellOutputWrapperClass = `.${CellOutputWrapper}`;
Expand Down Expand Up @@ -577,8 +574,8 @@ export class NativeCell extends React.Component<INativeCellProps> {
this.props.focusCell(cellId);
this.props.runByLine(cellId);
};
const cont = () => {
this.props.continue(cellId);
const stop = () => {
this.props.interruptKernel();
};
const step = () => {
this.props.focusCell(cellId);
Expand Down Expand Up @@ -616,18 +613,19 @@ export class NativeCell extends React.Component<INativeCellProps> {
<div className={toolbarClassName}>
<div className="native-editor-celltoolbar-middle">
<ImageButton
className={'image-button-empty'} // Just takes up space for now
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there the empy image button?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make the run by line button be in the same location after it starts. I used this empty button so that I wouldn't have to hard code some extra margin on the run by line button.

Additionally Jim was discussing having an F5 button in the future to 'continue' a cell. It would be where the empty button is now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, just the fact that it had a tooltip, onClick, ect.. seemed off for a spacer button. I guess visibility:hidden should take care of this, but I just wouldn't want it to be tabbable or screen readable.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay good point. Double checked. No tooltip, can't figure out how to tab through our window so couldn't check that.

However checking the tooltip made me realize it wasn't translated for stepping.

baseTheme={this.props.baseTheme}
onClick={cont}
tooltip={getLocString('DataScience.continueRunByLine', 'Stop')}
onClick={runCell}
tooltip={getLocString('DataScience.runCell', 'Run cell')}
hidden={this.isMarkdownCell()}
disabled={this.props.busy || this.props.runningByLine === DebugState.Run}
disabled={true}
>
<div className="codicon codicon-button">{CodIcon.Stop}</div>
<Image baseTheme={this.props.baseTheme} class="image-button-image" image={ImageName.Run} />
</ImageButton>
<ImageButton
baseTheme={this.props.baseTheme}
onClick={step}
tooltip={getLocString('DataScience.step', 'Run next line')}
tooltip={getLocString('DataScience.step', 'Run next line (F10)')}
hidden={this.isMarkdownCell()}
disabled={this.props.busy || this.props.runningByLine === DebugState.Run}
>
Expand All @@ -637,6 +635,19 @@ export class NativeCell extends React.Component<INativeCellProps> {
image={ImageName.RunByLine}
/>
</ImageButton>
<ImageButton
baseTheme={this.props.baseTheme}
onClick={stop}
tooltip={getLocString('DataScience.stopRunByLine', 'Stop')}
hidden={this.isMarkdownCell()}
disabled={false}
>
<Image
baseTheme={this.props.baseTheme}
class="image-button-image"
image={ImageName.Interrupt}
/>
</ImageButton>
</div>
<div className="native-editor-celltoolbar-divider" />
</div>
Expand Down
6 changes: 6 additions & 0 deletions src/datascience-ui/native-editor/nativeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,12 @@ ${buildSettingsCss(this.props.settings)}`}</style>
this.props.step(debuggingCell.cell.id);
}
event.stopPropagation();
} else {
// Otherwise if not debugging, run by line the current focused cell
const focusedCell = getSelectedAndFocusedInfo(this.props).focusedCellId;
if (focusedCell) {
this.props.runByLine(focusedCell);
}
}
break;
case 'F5':
Expand Down
4 changes: 4 additions & 0 deletions src/datascience-ui/react-common/imageButton.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
cursor: hand;
}

.image-button-empty {
visibility: hidden;
}

.image-button-inner-disabled-filter {
opacity: 0.5;
}
Expand Down