Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui/frontend): add shortcuts for tools #871

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ShaunSHamilton
Copy link

Adds shortcuts to tools. Global event listener is added for the following keydown events:

Keys Result
Ctrl + Alt + f Rust Fmt on the code
Ctrl + Alt + m Miri
Ctrl + Alt + x Macro Expansion
Ctrl + Alt + c Clippy

The above can easily be changed. However, certain combinations are reserved by different browsers.

What this looks like

I realise the background colour from the issue was probably for emphasis. So, am obviously happy to change/remove it.

image

Closes #844


Aside: More ESLint/editor rules should be added, as I constantly needed to avoid saving with formatting.

@tgross35
Copy link
Contributor

Could I suggest adding something like ctrl+alt+t to run tests? Helpful when you have both a main and #[test]s

@tgross35
Copy link
Contributor

There's also #814 which suggested capturing ctrl+s to run the code. That's the current behavior of the monaco editor, but it could be good to capture it for the others

}, []);

const shortcutMap = new Map([
[['Control', 'Alt', 'f'], handleRustFmt],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, shift+alt+f is the default VSCode shortcut for formatting a document on macOS and Windows (but not Linux, it seems?), so users of the Monaco editor might find that more familiar, although it doesn't use Control like the shortcuts propsed here.

On macOS at least (and I would guess on other OSes as well), some of these shortcuts seem to have uses already within the editor:

  • cmd+alt+f seems to open a find+replace dialog in ace and monaco
  • cmd+alt+c toggles case-sensitivity for searches in monaco

This PR looks like it has been open a while without much movement, but I just wanted to provide some feedback on the choice of shortcuts. If there is any interest in reviving this I think it would definitely be a nice feature to have!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add shortcut to run rustfmt
3 participants