You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In config.edn file, it is possible to add extra CodeMirror options using the :editor/extra-codemirror-options config map. But if you add the extraKeys option (used to specify extra key bindings for the editor), it is ignored.
This bug is due to the way the cm-options map is built in the following code:
Using merge function, if a key occurs in more than one map, the mapping from the latter (left-to-right) will be the mapping in the result. For this reason, extraKeys option in the last map (used to bind Esc key) overrides a custom extraKeys option contained in extra-codemirror-options map.
Why is extraKeys option important? According to the CodeMirror documentation and a issue in the official repository, using extraKeys option is the only way to map the Tab key to insert spaces instead of a tab character.
Reproduce the Bug
For example, in the config.edn file add the following configuration to map the Tab key to insert spaces instead of a tab character:
;; Extra CodeMirror options
:editor/extra-codemirror-options
{
:extraKeys {
"Tab" (fn [cm]
(.execCommand cm "indentMore"))
"Shift-Tab" (fn [cm]
(.execCommand cm "indentLess"))
}
}
Create a code block (```... ```)
Press the Tab key in the editor
Spaces should be inserted but a tab character is inserted instead
Expected Behavior
No response
Screenshots
No response
Desktop Platform Information
No response
Mobile Platform Information
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered:
We haven't seen any activity on this issue in a while 😴, and we just wanted to make sure that it's still relevant. If you're still experiencing this issue, you might find it helpful to update to the latest version of Logseq. The latest version includes bug fixes and new features that may help to resolve this issue, and you can download it from our website. If updating to the latest version doesn't help, please let us know by adding a comment 💬. We're here to help!
If the issue has been resolved or is no longer relevant, that's great news! 🎉
We'll go ahead and close this issue to keep our backlog organized. Please note that this issue will be closed automatically in 20 days if there is no further activity. If you need more time to resolve the issue or provide more information, please just let us know by adding a comment.
Thanks for your contributions to Logseq! If you have any other issues or feature requests, please don't hesitate to let us know. We always welcome pull requests too!
What happened?
In
config.edn
file, it is possible to add extra CodeMirror options using the:editor/extra-codemirror-options
config map. But if you add theextraKeys
option (used to specify extra key bindings for the editor), it is ignored.This bug is due to the way the
cm-options
map is built in the following code:logseq/src/main/frontend/extensions/code.cljs
Lines 231 to 241 in 700c977
Using
merge
function, if a key occurs in more than one map, the mapping from the latter (left-to-right) will be the mapping in the result. For this reason,extraKeys
option in the last map (used to bind Esc key) overrides a customextraKeys
option contained inextra-codemirror-options
map.Why is
extraKeys
option important? According to the CodeMirror documentation and a issue in the official repository, usingextraKeys
option is the only way to map the Tab key to insert spaces instead of a tab character.Reproduce the Bug
config.edn
file add the following configuration to map the Tab key to insert spaces instead of a tab character:Expected Behavior
No response
Screenshots
No response
Desktop Platform Information
No response
Mobile Platform Information
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: