-
Notifications
You must be signed in to change notification settings - Fork 12
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
[FireMonkey] setting keyMaps using CodeMirror advanced options no longer works #495
Comments
This can be done this way as well... but that is something to discuss with CodeMirror function getKeyMap(val) {
return typeof val == "string" && keyMap[val] ? keyMap[val] : val
}
This was changed since Mozilla validator complained about inline script when there is no After reverting to |
Haha, yeah, I must have started debugging this just as this post was being written... 😄 For others who may be confused right now: if everything seems fine, you've done no major changes, extension storage looks all good, yet CodeMirror just shows an empty editor—this is your issue. Remove any And apparently it's more or less fixed already, so outstanding work. Much appreciated and makes you realize how dependent on this add-on I've become, hehe. FireMonkey, Tridactyl, and uBlock Origin—trio that can do literally anything and get the web you like. ❤️ |
v2.58 uploaded.... let me know how it goes |
Yes the error still occurs. After some more debugging I have found the problem. The error occurs because the keymap javascript is not running before invoking codemirror. The keymap javascript adds itself to the keyMap object which contains the avaliable keymaps. When getKeyMap is called it returns undefined because the keymap javascript has not been able to add itself to the keyMap object. I set some breakpoints using the debugger and here is order in which things execute:
I have also tested this by hard coding the keymap javascript into the "options.html" file. When doing this, the keymap javascript is executed before the options.js file and the error does not occur. So to fix this error, somehow the the keymap javascript needs to be executed before the options.js file, or at least before calling the CodeMirror.fromTextArea function. Short of converting the keymaps to modules and importing them, I am not sure how to achieve this. |
Thank you for testing it. It was working before with the same code, so it seems that changes are might be related to changes in Firefox. My guess is that the async loading process takes too long.
Solutions:
PS. I cant produce the error when loading Also note:
|
I am using the sublime keymap, but the vim keymap gives me the same "next is undefined" error. If I hard coding the vim keymap javascript into the "options.html" file I do not get any errors. When the keyMap is loaded (line 661), The keymap script doesn't execute immediately. It doesn't actually run until after "CodeMirror.fromTextArea" (line 306, the call that causes the error) and "pref.customOptionsCSS" (line 1460) (which I believe signals the end of the initialization and the end of options.js correct?) Here is the whole call stack for the error if that helps:
I was able to get it working by using import and await in place of adding a src to the script tag. Here are the changes I made: Replace adding src attribute with import (line 662):
Make the process() function of the script class async to allow the use of await (line 658):
Make the Arrow Function for "getPref().then" async and add await to "script.process()" because "nav.process()" fails if run before "script.process()" finishes (line 1453).
Again this may not be the best way to do this (I am by no means a professional coder). This kinda goes along with your first solution of waiting for the keyMap to be loaded. I could not find any other way to load an external javascript file, execute it immediately and wait for it to finish. |
Thank you for testing. Can you test with FM v2.56? Which Firefox are you testing it on and which OS? re: |
I wet back and tested old versions, and the "next is undefined" error happens in every version since v2.43 when it was implemented.
I am using Windows 7 and am testing on both Firefox esr v91.11.0 as well as the latest v102.0.1.
I am just editing individual files and replacing them in the .xpi.
Ya, that is why I mentioned that might not be the best way. I could not find any other way to make it work without major changes to the code. |
Therefore, the error has come about due to changes to the Firefox since AFAIK it was working before. I will work on a solution. |
Looking at Stylus, it seems to load all the keyMaps all the time. https://github.com/openstyles/stylus/blob/ea388ea9a7004ec49ec0ba51eed17b521650247f/edit.html#L44-L46 |
Yes, the error happens with all of the key map files. It is looking like the best way to fix this is to do like you pointed out with Stylus and just load them all at once. No messy code to deal with. I ran into another issue that caused the error also. When changing keymap value in the advanced config, the same error would appear after hitting the save button. The error occurs because the the javascript for the new keymap has not been run. If all the keymaps are loaded at once, this issue would be avoided too. |
I was also able to reproduce the error when moving from toolbar popup -> script -> Info -> Edit If I go to Options and then click on a script to open an editor, the error doesn't show for me. |
v2.59 |
v2.59 uploaded.... let me know how it goes |
v2.59 works great! No errors and all the key maps work. |
In version 2.57, setting keyMaps in the CodeMirror section of the advanced settings no longer works. In the browser console I found the following error:
I was able to fix this error by changing the the function "getKeyMap" in "fm-codemirror.js" to:
Then there was another error:
The keyMap script src was getting updated after the page loaded with the proper javascript location, but the keymap script was still not being loaded. After looking at the changes between v2.56 an v2.57 I found that I was able to edit the file "options.html" and changed:
to:
After making these changes, everything is working correctly again. I don't know if these are the best ways to fix this issue, but this seems to be working fine for me.
The text was updated successfully, but these errors were encountered: