nicoespeon/vscode-slides

Preview markdown feature

Closed this issue ยท 4 comments

First really thank you for this extension !

Describe what could be improved

When the new markdown preview feature is enabled, I was wondering if it could be possible to open the markdown file directly in preview mode. This could prevent the double loading frame:

  • the first one to load the real markdown file
  • the second one to load the preview markdown file

Additional information

  • Version of the extension used: 3.1

I'll let @nicoespeon weigh in on this as well but during my development for it I had to manually invoke the VS Code action to render in the preview window. The problem with this is that VS Code reuses the Preview pane across all opened Markdown files which forced me to execute the preview command, listen for a slide change, close the preview, go back to where we left off, and go to the next slide.

I like this improvement suggestion, though, and I'll try and do some digging to see if we can get a more static parser in the mix so we don't have to do the double-load.

Yes, I noticed that too. In fact, I even mentioned it in the code ๐Ÿ˜

if (isActive) {
// Close & open markdown previews glitches on consecutive mardown slides.
// We could improve that if we know what the previous slide would be.
await editor.closeMarkdownPreview();
await editor.openPreviousFile();
await editor.previewIfMarkdown();
}

It's a bit tricky to solve, as @etbrow explained. I didn't found a simple solution yet.

I don't know if we can pass the "new file to open" data to the markdown preview directly, so we wouldn't have to open the raw markdown when we change slide.

[few minutes later]

In fact, I think it's possible ๐Ÿ˜

Looking at the ShowPreviewCommand code of VS Code, I see the execute() method takes some URIs as parameters: https://github.com/microsoft/vscode/blob/f44dc0853786a1a1c9f5dce5cd94941c2a795655/extensions/markdown-language-features/src/commands/showPreview.ts#L61

So it's possible to provide the URI of the file to open and avoid the glitch.

But even better, we could also open all the Previews right away, and probably close the raw Markdown files. If we manage to do so (and have the Previews at the correct positions), we'd have a proper previewMarkdownFiles behavior IMO.

So, thank you for the suggestion. After digging into it, it was not that hard to implement. It even simplified the code.

I published a new version of Slides with this improvement ๐Ÿ‘

You fixed it in one day. Really thank you ๐Ÿ˜ !
You are both really responsive, it's really appreciable ๐Ÿ‘

This extension could maybe one day replace PowerPoint presentation.