Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] - Toggle Custom Editor (Improved markdown support) #113298

Closed
jasonwilliams opened this issue Dec 22, 2020 · 20 comments
Closed

[Feature] - Toggle Custom Editor (Improved markdown support) #113298

jasonwilliams opened this issue Dec 22, 2020 · 20 comments
Assignees
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities markdown Markdown support issues
Milestone

Comments

@jasonwilliams
Copy link
Contributor

jasonwilliams commented Dec 22, 2020

This issue arises from the parent issue: #84520

Description

I would like to quickly toggle between 2 markdown states:

  • Source Code editor (This is the state you currently get by default)
  • Custom Editor (the preview editor you see when opening preview mode if the file is markdown)

Toggling between modes should take place in the same current window. This way you'll get a smooth create-read-modify experience. For references have a look at typora.io or notable.md where this is perfectly implemented.

Persistent State

When toggling between 2 states i would like the states to be persistent.
What i mean by this, is if I toggle a document to preview mode, when I go to open another document, I'm still in preview mode until I toggle back. This is the behaviour of many other markdown viewers and is pretty standard at this point, if it can keep state across sessions that would be even better.

Steps to reproduce:

Add this to your settings:

  "workbench.editorAssociations": [
    {
      "viewType": "vscode.markdown.preview.editor",
      "filenamePattern": "*.md"
    }
  ],

Then open a markdown file, you can toggle state by calling "Reopen Editor with..." then selecting one of the 2 options. Opening a new file resets this choice.

Requested changes

As per the discussion in #84520 we would like to see a keyboard-shortcut which can toggle between these 2 states, and keep persistence.

Implementation detail

#84520 (comment)

@sverg1 This should likely not be a markdown specific command but a generic for custom editors. Something like: toggle custom editor that would switch between VS Code's standard text editor and the custom one (i.e. the markdown preview)

Here's where the custom editor commands live:

const REOPEN_WITH_COMMAND_ID = 'reOpenWith';

The ICustomEditorService and IEditorService should have the functionality you need to implement this:

  • Getting the currently active editor.
  • Switching it to the custom editor or to the default text editor.

Since this change would be going into core VS Code, it should not hardcode anything markdown specific

@vscodebot
Copy link

vscodebot bot commented Dec 22, 2020

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@olajohn-ajiboye
Copy link

@jasonwilliams @mjbvz . I would like to tackle this if it's not been worked on yet.

@jasonwilliams
Copy link
Contributor Author

@olajohn-ajiboye no one is working on this so feel free!

@olajohn-ajiboye
Copy link

Thanks @jasonwilliams , I will start working on this. Am I able to ask for pointers from you if I need additional clarifications or who else can help?

@jasonwilliams
Copy link
Contributor Author

@olajohn-ajiboye sure you can ask here.

@mjbvz should hopefully be able to guide you too as he made the parent issue and created the custom editor

@mjbvz mjbvz added markdown Markdown support issues feature-request Request for new features or functionality labels Jan 16, 2021
@mjbvz
Copy link
Contributor

mjbvz commented Jan 16, 2021

The existing Toggle editor type command switches the type of the current editor so this feature request it to persist the choice too, correct? Maybe a newToggle default editor type command?

To start, look at the Toggle editor type command:

const activeEditorPane = this.editorService.activeEditorPane;

For the new command, you'll also want to save off the new setting. Here's an example of some code that does that:

@mjbvz mjbvz added the help wanted Issues identified as good community contribution opportunities label Jan 16, 2021
@olajohn-ajiboye
Copy link

Thanks for the heads-up @mjbvz , I will have another look at this.

@olajohn-ajiboye
Copy link

Hey @jasonwilliams @mjbvz , I am not able to reproduce the "Reopen Editor with..." option. I was able to see this option before, but it seems gone. Could this be due to an update?
Screenshot 2021-01-21 at 12 23 13

@jasonwilliams
Copy link
Contributor Author

@olajohn-ajiboye what version of VSCode are you using? Are you using insiders or stable?

@olajohn-ajiboye
Copy link

@jasonwilliams it's Version: 1.52.1. I am not sure if it's stable or insider.
Screenshot 2021-01-21 at 21 33 04

@jasonwilliams
Copy link
Contributor Author

jasonwilliams commented Mar 7, 2021

@mjbvz you able to do something about that? ^

@jasonwilliams
Copy link
Contributor Author

jasonwilliams commented Mar 7, 2021

@olajohn-ajiboye maybe it’s only on insiders

@jasonwilliams
Copy link
Contributor Author

Can we reopen this? It’s being looked at

@mjbvz mjbvz modified the milestones: Backlog Candidates, Backlog Mar 17, 2021
@mjbvz mjbvz reopened this Mar 17, 2021
@jasonwilliams
Copy link
Contributor Author

@mjbvz what's the purpose of Toggle editor type again? Can that not be retrofitted with the purpose of changing from source-code to preview on markdowns (or cycling through custom editors) ?

@mjbvz
Copy link
Contributor

mjbvz commented Mar 19, 2021

Toggle editor type toggles the type of the active editor. It's useful for quickly switching between a hex editor and a text editor for example

@jasonwilliams
Copy link
Contributor Author

@mjbvz is this issue still valid?

@mjbvz
Copy link
Contributor

mjbvz commented Dec 5, 2022

Thanks @jasonwilliams. Yes I'll close this since I think this was addressed. Please open new issues if some part of this still isn't working as expected

@mjbvz mjbvz closed this as completed Dec 5, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jan 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities markdown Markdown support issues
Projects
None yet
Development

No branches or pull requests

5 participants
@jasonwilliams @mjbvz @andreamah @olajohn-ajiboye and others