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

Change key bindings for folding in PGCodeMirror. #2594

Merged
merged 1 commit into from
Nov 12, 2024

Conversation

somiaj
Copy link
Contributor

@somiaj somiaj commented Oct 6, 2024

By default code mirror uses Shift-Ctrl-F for find/replace and Shift-Ctrl-G for find previous. These key bindings were overwritten when folding was added.

This changes the fold binding to Shift-Ctrl-W and unfold all to Shift-Ctrl-Q, so they no longer interfere with the find replace key bindings.

Note, I just picked key bindings close together, but if those who use folding have better suggestions, please share.

@drgrice1
Copy link
Member

drgrice1 commented Oct 6, 2024

Perhaps use Ctrl-Shift-[ (and Cmd-Shift-[ on MacOS) for code folding, and Ctrl-Shift-] (and Cmd-Shift-] on MacOS) for code unfolding instead. Those are the keybindings that CodeMirror 6 uses for this.

We are about to switch to CodeMirror 6 in any case, so this pull request will probably be somewhat short lived.

@drgrice1
Copy link
Member

drgrice1 commented Oct 6, 2024

By the way, CodeMirror 6 also uses Ctl-Alt-[ and Ctl-Alt-] for folding and unfolding all (of course with Cmd for MacOS instead).

@somiaj
Copy link
Contributor Author

somiaj commented Oct 6, 2024

Good suggestions, I discovered that Shift-Ctrl-W closes my firefox windows, trying to find keybindings that don't mess with other things.

@drgrice1
Copy link
Member

drgrice1 commented Oct 6, 2024

I just realized that CodeMirror 5 does not have a close for a single fold. It is just a toggle. So use Ctrl-Shift-[ for toggling a single fold, Ctrl-Alt-[ for folding all, and Ctrl-Alt-] for unfolding all.

@somiaj
Copy link
Contributor Author

somiaj commented Oct 6, 2024

@drgrice, how do you insert a [ in maketext? Escaping it didn't work with \[.

@somiaj somiaj force-pushed the code-mirror-key-bindings branch from be48b2d to 605e63b Compare October 6, 2024 01:50
@somiaj
Copy link
Contributor Author

somiaj commented Oct 6, 2024

Ahh figured it out in the docs, ~[.

@somiaj
Copy link
Contributor Author

somiaj commented Oct 6, 2024

Bindings updated to @drgrice1 suggestions. Even though these will be replaced soon, I'm going to apply them to my 2.19 install, I could make this a hotfix if others wanted the find/replace functionality back in 2.19's editor.

@somiaj somiaj force-pushed the code-mirror-key-bindings branch from 605e63b to 4c2bfe6 Compare October 6, 2024 02:06
@drgrice1
Copy link
Member

drgrice1 commented Oct 6, 2024

I think a hotfix is justified. Then this pull request will have some meaning!

@somiaj somiaj force-pushed the code-mirror-key-bindings branch 2 times, most recently from 2a63a22 to ed7a347 Compare October 8, 2024 19:19
@somiaj
Copy link
Contributor Author

somiaj commented Oct 8, 2024

@pstaabp can you check the keybindings on a mac. I updated to use the ones from codemirror 6. https://codemirror.net/docs/ref/#language.foldKeymap

By default code mirror uses Shift-Ctrl-F for find/replace
and Shift-Ctrl-G for find previous. These key bindings were
overwritten when folding was added.

This changes the fold binding to Shift-Ctrl-[ (or Shift-Cmd-[),
fold all to Ctrl-Alt-[ (Cmd-Alt-[) and unfold all to Ctrl-Alt-]
(Cmd-Alt-]), so they no longer interfere with the find/replace
key bindings.
@somiaj somiaj force-pushed the code-mirror-key-bindings branch from ed7a347 to a816947 Compare October 25, 2024 16:06
@pstaabp
Copy link
Member

pstaabp commented Nov 12, 2024

Ctrl-Shift-[ and -] switches tabs in Safari, so that's not good. Shift-Ctrl - [ and -] look to be open.

@Alex-Jordan Alex-Jordan merged commit 5289d8b into openwebwork:develop Nov 12, 2024
2 checks passed
Alex-Jordan added a commit that referenced this pull request Nov 12, 2024
Change key bindings for folding in PGCodeMirror. (Hotfix of #2594)
@somiaj somiaj deleted the code-mirror-key-bindings branch November 24, 2024 19:01
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.

4 participants