Skip to content
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
2 changes: 1 addition & 1 deletion src/datascience-ui/native-editor/nativeCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export class NativeCell extends React.Component<INativeCellProps> {
}
break;
case 's':
if (e.ctrlKey || (e.metaKey && getOSType() === OSType.OSX)) {
if ((e.ctrlKey && getOSType() !== OSType.OSX) || (e.metaKey && getOSType() === OSType.OSX)) {
// This is save, save our cells
this.props.stateController.save();
}
Expand Down
2 changes: 1 addition & 1 deletion src/datascience-ui/native-editor/nativeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ export class NativeEditor extends React.Component<INativeEditorProps, IMainState
// tslint:disable-next-line: no-suspicious-comment
// TODO: How to have this work for when the keyboard shortcuts are changed?
case 's': {
if (event.ctrlKey || (event.metaKey && getOSType() === OSType.OSX)) {
if ((event.ctrlKey && getOSType() !== OSType.OSX) || (event.metaKey && getOSType() === OSType.OSX)) {
// This is save, save our cells
this.stateController.save();
this.stateController.sendCommand(NativeCommandType.Save, 'keyboard');
Expand Down
21 changes: 20 additions & 1 deletion src/test/datascience/nativeEditor.functional.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,8 @@ for _ in range(50):
}
});

test('Test save using the key \'ctrl+s\'', async () => {
test('Test save using the key \'ctrl+s\' on Windows', async () => {
(window.navigator as any).platform = 'Win';
clickCell(0);

await addCell(wrapper, ioc, 'a=1\na', true);
Expand All @@ -987,6 +988,24 @@ for _ in range(50):
assert.ok(!editor!.isDirty, 'Editor should not be dirty after saving');
});

test('Test save using the key \'ctrl+s\' on Mac', async () => {
(window.navigator as any).platform = 'Mac';
clickCell(0);

await addCell(wrapper, ioc, 'a=1\na', true);

const notebookProvider = ioc.get<INotebookEditorProvider>(INotebookEditorProvider);
const editor = notebookProvider.editors[0];
assert.ok(editor, 'No editor when saving');
const savedPromise = createDeferred();
editor.saved(() => savedPromise.resolve());

simulateKeyPressOnCell(1, { code: 's', ctrlKey: true });

await expect(waitForCondition(() => savedPromise.promise.then(() => true).catch(() => false), 1_000, 'Timedout')).to.eventually.be.rejected;
assert.ok(editor!.isDirty, 'Editor be dirty as nothing got saved');
});

test('Test save using the key \'cmd+s\' on a Mac', async () => {
(window.navigator as any).platform = 'Mac';

Expand Down