HTML icon indicating copy to clipboard operation
HTML copied to clipboard

Eval-on-save requires two eval-entire-file commands

Open kenny-evitt opened this issue 9 years ago • 1 comments

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:

  1. Open LT.
  2. I opened my main HTML file.
  3. I eval-ed the entire HTML file. A browser tab opened with the web page.
  4. I made a change to the HTML file and saved it – the browser tab was not affected.
  5. I eval-ed the entire HTML file – the browser tab was refreshed.
  6. 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.

kenny-evitt avatar Nov 10 '15 22:11 kenny-evitt

@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.

kenny-evitt avatar Nov 10 '15 23:11 kenny-evitt