-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: show config preview on click, not automatically
- Loading branch information
Showing
4 changed files
with
51 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import * as vscode from "vscode"; | ||
import { My } from "../my"; | ||
import { PreviewPanel } from "./Preview"; | ||
|
||
export function registerShowPreviewCommand(my: My): vscode.Disposable[] { | ||
const showPanel = () => PreviewPanel.render(my.context.extensionUri); | ||
|
||
return [ | ||
vscode.commands.registerCommand("configEditor.open", async () => { | ||
// Render the preview on click | ||
if (my.configDocument) await showPanel(); | ||
}), | ||
|
||
my.onConfigDocumentChanged(async (change) => { | ||
// Show/hide the preview button | ||
await vscode.commands.executeCommand( | ||
"setContext", | ||
"configEditor.hasConfigDocument", | ||
!!change.current, | ||
); | ||
|
||
// Update open previews, but don't automatically open a new one | ||
if (change.current && PreviewPanel.currentPanel) { | ||
await showPanel(); | ||
} | ||
}), | ||
]; | ||
} |