Fix for mode switch

This commit is contained in:
Elio Struyf
2022-04-20 11:19:23 +02:00
parent 55a14b3fbe
commit b232c55843
4 changed files with 11 additions and 2 deletions

View File

@@ -5,6 +5,7 @@
### 🎨 Enhancements
- [#263](https://github.com/estruyf/vscode-front-matter/issues/263): WYSIWYG string field option
- [#308](https://github.com/estruyf/vscode-front-matter/issues/308): New `File` field
- [#314](https://github.com/estruyf/vscode-front-matter/issues/314): New preview actions to open the page in the browser and refresh the preview
- [#322](https://github.com/estruyf/vscode-front-matter/issues/322): Show parent folder name when file is an index page (`index.md` / `_index.md`)
@@ -12,6 +13,10 @@
- [#316](https://github.com/estruyf/vscode-front-matter/issues/316): Surpress file parsing errors when closing the dashboard
### 🐞 Fixes
- Hide the view mode action from the Front Matter panel if no custom modes are defined
## [7.1.2] - 2022-04-11
### 🐞 Fixes

View File

@@ -1692,7 +1692,7 @@
{
"command": "frontMatter.mode.switch",
"group": "navigation@1",
"when": "view == frontMatter.explorer"
"when": "view == frontMatter.explorer && frontMatter:has:modes == true"
},
{
"command": "frontMatter.dashboard",

View File

@@ -9,6 +9,8 @@ export const CONTEXT = {
backer: "frontMatter:backers:supporter",
isValidFile: "frontMatter:file:isValid",
hasViewModes: "frontMatter:has:modes",
isSnippetsDashboardEnabled: "frontMatter:dashboard:snippets:enabled",
isDataDashboardEnabled: "frontMatter:dashboard:data:enabled",
};

View File

@@ -2,7 +2,7 @@ import { ModeListener } from './../listeners/general/ModeListener';
import { SETTING_GLOBAL_ACTIVE_MODE, SETTING_GLOBAL_MODES } from './../constants/settings';
import { commands, StatusBarAlignment, StatusBarItem, ThemeColor, window } from "vscode";
import { Settings } from "../helpers/SettingsHelper";
import { COMMAND_NAME } from '../constants';
import { COMMAND_NAME, CONTEXT } from '../constants';
import { Mode } from '../models';
@@ -36,9 +36,11 @@ export class ModeSwitch {
const modes = Settings.get<string | null>(SETTING_GLOBAL_MODES);
if (!modes || modes.length === 0) {
ModeSwitch.statusBarElm.hide();
commands.executeCommand('setContext', CONTEXT.hasViewModes, false);
return;
}
commands.executeCommand('setContext', CONTEXT.hasViewModes, true);
ModeSwitch.setText();
}