HTML
HTML copied to clipboard
Eval-on-save requires two eval-entire-file commands
This was originally reported in LightTable/LightTable#2000.
I was able to reproduce this with a source build (since the 0.8.0-alpha release) on a Windows 7 computer. The steps to reproduce:
- Open LT.
- I opened my main HTML file.
- I eval-ed the entire HTML file. A browser tab opened with the web page.
- I made a change to the HTML file and saved it – the browser tab was not affected.
- I eval-ed the entire HTML file – the browser tab was refreshed.
- I made another change to the HTML file and saved it – this time the browser tab was refreshed.
I'm using the file web.html from this repo.
@cldwalker I modified the eval-on-save
behavior in my local copy of the HTML plugin to this:
(behavior ::eval-on-save
:triggers #{:save}
:reaction (fn [editor]
(let [editor-default-client (-> @editor :client :default)]
(lt.objs.console/log (if editor-default-client "if" "not-if"))
(when (and editor-default-client
(not (clients/placeholder? editor-default-client)))
(object/raise html-lang :eval! {:origin editor
:info (assoc (@editor :info)
:code (ed/->val (:ed @editor)))})))))
I'm getting not-if
logged in the console when I save the HTML file (when I follow steps 1-4 above).
Incidentally, is there a better way to inspect this behavior than what I did? I added a watch to the @editor
expression but it logs a stack overflow exception.
If I add the same code to the CSS plugin, I get if
logged in the console when I save the CSS file.