-
Notifications
You must be signed in to change notification settings - Fork 138
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
Toggle multiline comments in editor with cmd-/ #2276
Comments
Hey @outoftime, I've been working on a solution to this with @paulproteus, using CodeMirror's blockComment function. If I submit a pull request for the feature, would you want to enable it? If not, no worries, I'm learning a lot in the process anyway. :) |
Sure! |
Hey @outofotime! We (@paulproteus and I) worked on this today, and came up with this implementation:
This would directly configure CodeMirror to respond to the Ctrl-/ (or Cmd-/) event, rather than pass it through Redux. The main reason we went that route was because we weren't sure if we could call The main question -- is that OK to ask CodeMirror to modify the contents of the editor by itself? If not, then we'll need a way to get the current selection in a Redux context, and also to figure out what to do with it (can we call Looking for advice, and also, if this is more trouble than it's worth, we can switch to a different issue. Wanted to do this to learn more. :) One thing we noticed while leaving this comment is that we could easily write a function that takes the |
@thayerve I think you can also use the import 'codemirror/addon/comment/comment';
...
useEffect(() => {
const editor = editorRef.current;
const modifier = bowser.isOS('macOS') ? 'Cmd' : 'Ctrl';
editor.setOption('extraKeys', {
[`${modifier}-I`]: onAutoFormat,
[`${modifier}-S`]: onSave,
[`${modifier}-/`]: cm => cm.toggleComment({indent: true}),
});
}, [onAutoFormat, onSave]); |
@outoftime since #2386 is merged, I propose you mark this issue as closed since I think it's now fixed! |
Submitter: Peter Jablonski
Love the Code Mirror update!
It looks like the multiline comment feature is not enabled (cmd + /)
The text was updated successfully, but these errors were encountered: