Qeole / Enlight

Firefox add-on providing syntax highlighting for raw code, based on the highlight.js project.
Mozilla Public License 2.0
44 stars 2 forks source link

Settings not saved #9

Closed Qeole closed 4 years ago

Qeole commented 6 years ago

See https://addons.mozilla.org/fr/firefox/addon/enlight/reviews/1135473

Settings for autohilite and other one are not saved, so I must click 'autodetect' each time.

At this time I don't know how to reproduce.

Qeole commented 6 years ago

Not sure if related, but I noticed that the two checkboxes controlling auto-hl and line numbers on the preferences page fail to be checked when the page loads, even if the related preferences were activated. The preferences can still be set and are saved normally (at least on my setup), the boxes just aren't checked. Something like this should help.

diff --git a/options/save-restore.js b/options/save-restore.js
index c39ba868ec79..a8188c3046bd 100644
--- a/options/save-restore.js
+++ b/options/save-restore.js
@@ -24,7 +24,11 @@ function onError(error) {
 function restoreOption(aId, aDefault) {
     let gettingItem = browser.storage.local.get(aId);
     gettingItem.then((res) => {
-        document.getElementById(aId).value = res[aId] || aDefault;
+        let element = document.getElementById(aId);
+        if (element.tagName == "CHECKBOX")
+            document.getElementById(aId).checked = res[aId] || aDefault;
+        else
+            document.getElementById(aId).value = res[aId] || aDefault;
     }, onError);
 }

Adding the patch above for the record and because I don't have time to test and push it right now, but since that other bug does not prevent preferences to be saved, I must assume this is not what OP meant.

ilya-lazarev commented 6 years ago

My OS is windows 7 x64 and Firefox 60.0.2

Qeole commented 6 years ago

Thank you! This is not my default setup but I should be able to find a machine with W7, I'll try to reproduce.

Qeole commented 6 years ago

So I just tried with the same OS and Firefox version, but I could not reproduce the issue :(.

Are you sure that you are not experiencing the issue described above—that is, the checkboxes always appear unchecked when opening the add-on preferences page, but the preferences being saved nevertheless? (I'm about to push a fix for that to AMO.)

If the issue persists, I'm sorry, I'll try to have another look at the code but don't really know how to debug this :(.