Skip to content

Commit c9f1a28

Browse files
christianalfoniCompuIves
authored andcommitted
Improve experience of enabling VIM (codesandbox#3128)
1 parent af04a07 commit c9f1a28

File tree

1 file changed

+29
-8
lines changed
  • packages/app/src/app/pages/common/Modals/PreferencesModal/EditorPageSettings/EditorSettings

1 file changed

+29
-8
lines changed

packages/app/src/app/pages/common/Modals/PreferencesModal/EditorPageSettings/EditorSettings/index.tsx

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import React from 'react';
1+
import { Alert } from 'app/components/Alert';
2+
import Modal from 'app/components/Modal';
23
import { useOvermind } from 'app/overmind';
4+
import React from 'react';
35

46
import {
5-
Title,
6-
SubContainer,
7-
PreferenceContainer,
87
PaddedPreference,
8+
PreferenceContainer,
9+
SubContainer,
910
SubDescription,
11+
Title,
1012
} from '../../elements';
1113
import { VSCodePlaceholder } from '../../VSCodePlaceholder';
1214

@@ -16,6 +18,8 @@ const isSafari: boolean = /^((?!chrome|android).)*safari/i.test(
1618
const isFF: boolean = navigator.userAgent.toLowerCase().includes('firefox');
1719

1820
export const EditorSettings: React.FC = () => {
21+
const [showModal, setShowModal] = React.useState(false);
22+
1923
const {
2024
state: {
2125
preferences: { settings },
@@ -27,7 +31,10 @@ export const EditorSettings: React.FC = () => {
2731

2832
const bindValue = (name: string) => ({
2933
value: settings[name],
30-
setValue: (value: any) => settingChanged({ name, value }),
34+
setValue: (value: any) => {
35+
settingChanged({ name, value });
36+
setShowModal(true);
37+
},
3138
});
3239

3340
return (
@@ -40,13 +47,13 @@ export const EditorSettings: React.FC = () => {
4047
{/* {Vim mode does not work on FF or Safari */}
4148
<PreferenceContainer disabled={isSafari || isFF}>
4249
<PaddedPreference
43-
title="VIM Mode"
50+
title="Enable VIM extension"
4451
type="boolean"
4552
{...bindValue('vimMode')}
4653
/>
4754
<SubDescription>
48-
This will enable the VSCodeVim extension, you need to reload the
49-
page to see the effects
55+
Toggling the VIM extension will require a refresh. When enabled, use
56+
the command palette to control VIM
5057
</SubDescription>
5158
</PreferenceContainer>
5259
{isSafari || isFF ? (
@@ -58,6 +65,20 @@ export const EditorSettings: React.FC = () => {
5865
The VIM extension currently only works on Chrome and Microsoft Edge.
5966
</SubDescription>
6067
) : null}
68+
<Modal
69+
isOpen={showModal}
70+
onClose={() => setShowModal(false)}
71+
width={400}
72+
>
73+
<Alert
74+
title="Toggle VIM extension"
75+
body="You need to refresh the browser for this to take effect, do you want to do that now?"
76+
onCancel={() => setShowModal(false)}
77+
onConfirm={() => {
78+
location.reload(true);
79+
}}
80+
/>
81+
</Modal>
6182
</SubContainer>
6283
</div>
6384
);

0 commit comments

Comments
 (0)