Skip to content

Commit 0e917dd

Browse files
authored
Merge pull request #1732 from vulongphan/update/tidy-code-shortcut
Add Cmd+Shift+F as tidy code shortcut and prevent browser default behaviour
2 parents 9687be8 + 3cef359 commit 0e917dd

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

client/components/Nav.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,9 @@ class Nav extends React.PureComponent {
422422
onBlur={this.handleBlur}
423423
>
424424
{this.props.t('Nav.Edit.TidyCode')}
425-
<span className="nav__keyboard-shortcut">{'\u21E7'}+Tab</span>
425+
<span className="nav__keyboard-shortcut">
426+
{metaKeyName}+{'\u21E7'}+F
427+
</span>
426428
</button>
427429
</li>
428430
<li className="nav__dropdown-item">

client/components/__test__/__snapshots__/Nav.test.jsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ exports[`Nav renders correctly 1`] = `
8585
<span
8686
class="nav__keyboard-shortcut"
8787
>
88-
⇧+Tab
88+
⌃+⇧+F
8989
</span>
9090
</button>
9191
</li>

client/modules/IDE/components/Editor.jsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ const beautifyHTML = beautifyJS.html;
6262
window.JSHINT = JSHINT;
6363
window.CSSLint = CSSLint;
6464
window.HTMLHint = HTMLHint;
65-
delete CodeMirror.keyMap.sublime['Shift-Tab'];
6665

6766
const IS_TAB_INDENT = false;
6867
const INDENTATION_AMOUNT = 2;
@@ -168,8 +167,14 @@ class Editor extends React.Component {
168167
});
169168

170169
this._cm.on('keydown', (_cm, e) => {
171-
// 9 === Tab
172-
if (e.keyCode === 9 && e.shiftKey) {
170+
// 70 === f
171+
if (
172+
((metaKey === 'Cmd' && e.metaKey) ||
173+
(metaKey === 'Ctrl' && e.ctrlKey)) &&
174+
e.shiftKey &&
175+
e.keyCode === 70
176+
) {
177+
e.preventDefault();
173178
this.tidyCode();
174179
}
175180
});

client/modules/IDE/components/KeyboardShortcutModal.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ function KeyboardShortcutModal() {
2424
</p>
2525
<ul className="keyboard-shortcuts__list">
2626
<li className="keyboard-shortcut-item">
27-
<span className="keyboard-shortcut__command">{'\u21E7'} + Tab</span>
27+
<span className="keyboard-shortcut__command">
28+
{metaKeyName} + {'\u21E7'} + F
29+
</span>
2830
<span>{t('KeyboardShortcuts.CodeEditing.Tidy')}</span>
2931
</li>
3032
<li className="keyboard-shortcut-item">

0 commit comments

Comments
 (0)