Skip to content

Commit

Permalink
Bind markdown switch button shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
cweijan committed Jul 15, 2024
1 parent d4a3f3c commit 5c1072d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@
"command": "office.html.preview",
"key": "ctrl+shift+v",
"when": "editorTextFocus && editorLangId == html"
},
{
"command": "office.markdown.switch",
"key": "ctrl+alt+e",
"mac": "ctrl+cmd+e",
"when": "editorTextFocus && editorLangId == markdown"
}
],
"menus": {
Expand Down
4 changes: 3 additions & 1 deletion src/service/markdownService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ export class MarkdownService {
}

public switchEditor(uri: vscode.Uri) {
const type = vscode.window.activeTextEditor ? 'cweijan.markdownViewer' : 'default';
const editor = vscode.window.activeTextEditor;
if (!uri) uri = editor?.document.uri;
const type = editor ? 'cweijan.markdownViewer' : 'default';
vscode.commands.executeCommand('vscode.openWith', uri, type);
}

Expand Down

0 comments on commit 5c1072d

Please sign in to comment.