Skip to content

Commit 8d673b2

Browse files
authored
CHANGED: preview/nextSideview shortcut changed to ctrl+shift+arrow as the previous one was used in certain Linux desktops (#54)
CHANGED: navHistory shortcut changed to mod+arrow (Mac) and alt+arrow(Linux, Win), like in browsers FIXED: crash when calling navHistory shortcuts and history is empty ADDED: navHistory shortcuts in shortcuts dialog
1 parent c975a9e commit 8d673b2

File tree

3 files changed

+33
-8
lines changed

3 files changed

+33
-8
lines changed

src/components/App.tsx

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { shouldCatchEvent, isEditable } from "../utils/dom";
2121
import { WithMenuAccelerators, Accelerators, Accelerator, sendFakeCombo } from "./WithMenuAccelerators";
2222
import { remote } from 'electron';
2323
import classnames from 'classnames';
24-
import { isPackage, isWin } from '../utils/platform';
24+
import { isPackage, isWin, isMac } from '../utils/platform';
2525
import { TabDescriptor } from "./TabList";
2626
import { getLocalizedError } from "../locale/error";
2727

@@ -336,13 +336,13 @@ class App extends React.Component<WithNamespaces, IState> {
336336
/>
337337
<Hotkey
338338
global={true}
339-
combo="ctrl + alt + right"
339+
combo="ctrl + shift + right"
340340
label={t('SHORTCUT.MAIN.NEXT_VIEW')}
341341
onKeyDown={this.onNextView}
342342
/>
343343
<Hotkey
344344
global={true}
345-
combo="ctrl + alt + left"
345+
combo="ctrl + shift + left"
346346
label={t('SHORTCUT.MAIN.PREVIOUS_VIEW')}
347347
onKeyDown={this.onNextView}
348348
/>
@@ -353,12 +353,30 @@ class App extends React.Component<WithNamespaces, IState> {
353353
preventDefault={true}
354354
onKeyDown={this.onReloadFileView}
355355
/> */}
356-
<Hotkey
356+
{isMac && (<Hotkey
357+
global={true}
358+
combo="mod + left"
359+
label={t('SHORTCUT.ACTIVE_VIEW.BACKWARD_HISTORY')}
360+
onKeyDown={this.backwardHistory}
361+
/>)}
362+
{!isMac && (<Hotkey
357363
global={true}
358364
combo="alt + left"
359365
label={t('SHORTCUT.ACTIVE_VIEW.BACKWARD_HISTORY')}
360366
onKeyDown={this.backwardHistory}
361-
/>
367+
/>)}
368+
{isMac && (<Hotkey
369+
global={true}
370+
combo="mod + right"
371+
label={t('SHORTCUT.ACTIVE_VIEW.FORWARD_HISTORY')}
372+
onKeyDown={this.forwardHistory}
373+
/>)}
374+
{!isMac && (<Hotkey
375+
global={true}
376+
combo="alt + right"
377+
label={t('SHORTCUT.ACTIVE_VIEW.FORWARD_HISTORY')}
378+
onKeyDown={this.forwardHistory}
379+
/>)}
362380
<Hotkey
363381
global={true}
364382
combo="alt + right"

src/components/dialogs/ShortcutsDialog.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as React from "react";
22
import { Dialog, Classes, Button, KeyCombo } from "@blueprintjs/core";
33
import { withNamespaces, WithNamespaces } from "react-i18next";
4+
import { isMac } from "../../utils/platform";
45

56
interface IShortcutsProps extends WithNamespaces {
67
isOpen: boolean;
@@ -23,8 +24,8 @@ class ShortcutsDialogClass extends React.Component<IShortcutsProps>{
2324
{ combo: "ctrl + alt + right", label: t('SHORTCUT.MAIN.NEXT_VIEW') },
2425
{ combo: "ctrl + alt + left", label: t('SHORTCUT.MAIN.PREVIOUS_VIEW') },
2526
{ combo: "mod + r", label: t('SHORTCUT.MAIN.RELOAD_VIEW') },
26-
{ combo: "alt + left", label: t('SHORTCUT.ACTIVE_VIEW.BACKWARD_HISTORY') },
27-
{ combo: "alt + right", label: t('SHORTCUT.ACTIVE_VIEW.FORWARD_HISTORY') },
27+
{ combo: isMac && "mod + left" || "alt + left", label: t('SHORTCUT.ACTIVE_VIEW.BACKWARD_HISTORY') },
28+
{ combo: isMac && "mod + right" || "alt + right", label: t('SHORTCUT.ACTIVE_VIEW.FORWARD_HISTORY') },
2829
{ combo: "escape", label: t('SHORTCUT.LOG.TOGGLE') },
2930
{ combo: "mod + s", label: t('SHORTCUT.MAIN.KEYBOARD_SHORTCUTS') },
3031
{ combo: "mod + ,", label: t('SHORTCUT.MAIN.PREFERENCES') },
@@ -33,6 +34,8 @@ class ShortcutsDialogClass extends React.Component<IShortcutsProps>{
3334
],
3435
// group: t('SHORTCUT.GROUP.ACTIVE_VIEW')
3536
[
37+
{ combo: isMac && "mod + left" || "alt + left", label: t('SHORTCUT.ACTIVE_VIEW.BACKWARD_HISTORY') },
38+
{ combo: isMac && "mod + right" || "alt + left", label: t('SHORTCUT.ACTIVE_VIEW.FORWARD_HISTORY') },
3639
{ combo: "meta + c", label: t('SHORTCUT.ACTIVE_VIEW.COPY') },
3740
{ combo: "meta + v", label: t('SHORTCUT.ACTIVE_VIEW.PASTE') },
3841
{ combo: "mod + shift + c", label: t('SHORTCUT.ACTIVE_VIEW.COPY_PATH') },

src/state/fileState.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,13 @@ export class FileState {
9999
newCurrent = length - 1;
100100
}
101101

102+
if (newCurrent === this.current) {
103+
return;
104+
}
105+
102106
this.current = newCurrent;
103107

104-
const path = history[current + dir];
108+
const path = history[newCurrent];
105109

106110
return this.cd(path, '', true, true)
107111
.catch(() => {

0 commit comments

Comments
 (0)