Skip to content

VSCode Plugin: preview of markdown files with space in name fails for quarto projects #852

@daniel-eder

Description

@daniel-eder

Bug description

When previewing a (q)md file that has a space in the name using the "preview" icon in the vs code editor, the opened preview url is truncated at the first space.

E.g. http://localhost:7278/Draft/13 About [17].html becomes http://localhost:7278/Draft/13

This seems to be the same issue as #240.
While the commit that closed #240 (421e4f9) introduces a more robust regex (that correctly matches the above example), it seems to fall back to previewCommandUrl_ matched with kLocalPreviewRegex in apps/vscode/src/providers/preview/preview.ts

This only happens when using a quarto project. Rendering an individual file without _quarto.yml present works.
Presumably this is the cause because for individual files the preview url is just host:port without a path.

Steps to reproduce

  1. Create an empty folder.
  2. Create a _quarto.yml file with minimal content for a project:
    project:
      type: default
    
  3. Create a subfolder "Draft".
  4. In that folder, create a qmd file with a space in it's name, e.g. 13 About [17].qmd
  5. Click the preview button
  6. Observe that quarto preview prints the correct url in the terminal
  7. Observe that the actual preview browser opened navigates to http://localhost:<port>/Draft/13

Actual behavior

The preview browser opens http://localhost:<port>/Draft/13

Expected behavior

The preview browser opens http://localhost:<port>/Draft/13 About [17].html

Your environment

  • VSCode 1.105.1
  • Windows 11
  • Quarto extension version 1.126.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions