diff --git a/src/datascience-ui/native-editor/nativeCell.tsx b/src/datascience-ui/native-editor/nativeCell.tsx index c18aa6c57040..47e08ec646d8 100644 --- a/src/datascience-ui/native-editor/nativeCell.tsx +++ b/src/datascience-ui/native-editor/nativeCell.tsx @@ -252,7 +252,7 @@ export class NativeCell extends React.Component { } 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(); } diff --git a/src/datascience-ui/native-editor/nativeEditor.tsx b/src/datascience-ui/native-editor/nativeEditor.tsx index d6898aaab5c6..87758d27a2f2 100644 --- a/src/datascience-ui/native-editor/nativeEditor.tsx +++ b/src/datascience-ui/native-editor/nativeEditor.tsx @@ -324,7 +324,7 @@ export class NativeEditor extends React.Component { + 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); @@ -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); + 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';