Giter Club home page Giter Club logo

Comments (13)

memeplex avatar memeplex commented on June 9, 2024 1

Mmmm, thanks again. Anyway I think the effort is doomed to fail because variable expansion doesn't seem to work for inputs:

  "inputs": [
    {
      "id": "preview-html",
      "type": "command",
      "command": "livePreview.start.preview.atFileString",
      "args": "${relativeFileDirname}/${fileBasenameNoExtension}.html"
    }
  ]
image

I guess I'm going to manually open the preview :(

from vscode-livepreview.

meganrogge avatar meganrogge commented on June 9, 2024 1

@andreamah it looks like we don't resolve arguments, so at the moment, it's up to the extension to do so

https://github.com/microsoft/vscode/blob/dcafd8876c9365ca3fc6fe0f449aaa9a16570c15/src/vs/workbench/services/configurationResolver/browser/baseConfigurationResolverService.ts#L364

from vscode-livepreview.

andreamah avatar andreamah commented on June 9, 2024

You can use the command palette to run > Live Preview: Show Preview. If you want it to update when the script updates it, you can set "livePreview.autoRefreshPreview": "On Changes to Saved Files" in your settings. Does this help?

from vscode-livepreview.

memeplex avatar memeplex commented on June 9, 2024

Not really. What you describe is exactly what I'm doing now. I'm not saying it's bad, just that it requires to load the html first, which is a byproduct of a compilation, I'm not actually working on the html itself. I would like that this watchdog could invoke code <url> or code <html> after the compilation and then the preview automatically opens. Perhaps code <html> would conflict with the intention of opening the source html instead, which one may argue is the natural behavior for a text editor, but I guess there is some way to define a url that's handled by a particular extension, isn't there?

from vscode-livepreview.

andreamah avatar andreamah commented on June 9, 2024

Oh, are you looking for something that can be invoked via a command of some sort to preview? We had an issue here #368 about having a 'call' for starting the server, but that didn't include previewing. There's also a way of configuring a task to preview, which you could attach to a keybinding: #388. I think that might be the closest to what you want you could use.

from vscode-livepreview.

memeplex avatar memeplex commented on June 9, 2024

That may be useful indeed. I'm already running the watchdog from a background task so I guess I could add to it a dependency on a new task that opens the preview. I'm going to give it a try. I'm closing this for now and in any case I'll reopen it if I run into further difficulties. Thanks!

from vscode-livepreview.

memeplex avatar memeplex commented on June 9, 2024

Just one more question related to this, if you don't mind:

"On Changes to Saved Files"

I was using this setting but I realized that there were lots of extra reloadings, so I ended up turning autoreload off and opening a websocket client in the page then notifying it from the watchdog after each successful compilation.

Just to understand, the previewer has no notion of which file is being previewed, right? So every open file in the workspace or similar is monitored for save events?

This is unfortunate in my case because the sequence is more or less like this:

  1. I save the markdown file I'm editing
  2. The watchdog triggers a compilation and at almost the same time the page is reloaded
  3. The compilation generates an updated html

So the previewer may have updated the page too early, and since the html is not open nor explicitly saved from Code, but just changed at the filesystem level, I'm afraid its changes may not be displayed.

from vscode-livepreview.

andreamah avatar andreamah commented on June 9, 2024

Yes, unfortunately, that is what happens. the refresh will trigger on any workspace change because it's more complicated to follow what would change based on which file changes. You can try modifying livePreview.previewDebounceDelay to a larger number, then perhaps it will just refresh once and on time.

from vscode-livepreview.

memeplex avatar memeplex commented on June 9, 2024

I see, fortunately I was able to work around that.

I'm trying to follow your advice regarding #388 (comment), but bumping into:

2024-03-08 15:56:54.510 [error] [Extension Host] Tried to open a non-file URI with file opener
2024-03-08 15:56:54.514 [error] The "path" argument must be of type string. Received undefined: Error: The "path" argument must be of type string. Received undefined

I tried using a url-like expression like "args": "file:///Users/carlos/Desktop/test.html" but to no avail.

from vscode-livepreview.

memeplex avatar memeplex commented on June 9, 2024

Oh, this fixed the issue: #388 (comment)

Anyway I would like to understand the problem above. Does atFile expect a URL object that can't be conveyed by using a URL string representation from tasks.json?

from vscode-livepreview.

andreamah avatar andreamah commented on June 9, 2024

I think that a full absolute path like C:/Users/andreamah/OneDrive - Microsoft/Documents/vscode-livepreview/test-workspace/page0.html worked for me. So if you look at the comment you linked and replace the "{path_to_preview}" to a string like what I have above.

from vscode-livepreview.

andreamah avatar andreamah commented on June 9, 2024

I believe that the URI parser had difficulty parsing that string for some reason- aka calling vscode.Uri.file() on it errored out.

from vscode-livepreview.

andreamah avatar andreamah commented on June 9, 2024

@meganrogge curious: is variable expansion supposed to work here, or is this handled by the individual extension?

  "inputs": [
    {
      "id": "preview-html",
      "type": "command",
      "command": "livePreview.start.preview.atFileString",
      "args": "${relativeFileDirname}/${fileBasenameNoExtension}.html"
    }
  ]
image

from vscode-livepreview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.