Skip to content

Commit

Permalink
#9 - Clean start setting
Browse files Browse the repository at this point in the history
  • Loading branch information
estruyf committed Jul 28, 2021
1 parent a7fb6e5 commit d432fa6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ All notable changes to the "eliostruyf.vscode-hide-comments" extension will be d

## [1.3.0]

- Introduced new `hideComments.defaultEnabled` setting to control the default behavior of the extension.
- [#8](https://github.com/estruyf/vscode-hide-comments/issues/8): Introduced new `hideComments.defaultEnabled` setting to control the default behavior of the extension.
- [#9](https://github.com/estruyf/vscode-hide-comments/issues/9): Introduced new `hideComments.cleanStart` setting to control to always show the comments on startup.

## [1.2.0]

Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,18 @@ This extension started as a joke for people who do not like to see comments in t
## Usage

When you have installed this extension, each time you open VSCode, it checks if comments are shown or not. If comments are visible, it will ask you if you want to hide these for the current project.
When the extension is installed. You can use the `Hide Comments` commands to show or hide the comments.

If you want, you can also let the extension ask you each time when you start a new instance if you want to hide the comments. You can do this by enabling the `hideComments.defaultEnabled` setting. When this is set to `true`, you will get the following notification when you start a new instance:

![Do you want to hide the comments of this project?](./assets/hide-comments-dialog.png)

When you choose **Yes** it will at the settings to your user settings for this project. If you decide **No**, nothing will happen at all.

> You can disable this default behaviour by changing the `hideComments.defaultEnabled` setting to `false`.
## Settings

- `hideComments.defaultEnabled`: Define if you want to enable or disable the extension on startup of Visual Studio Code. Default: `true`.
- `hideComments.defaultEnabled`: Define if you want to enable or disable the extension on startup of Visual Studio Code. Default: `false`.
- `hideComments.cleanStart`: Define if you want to start each instance by showing the comments in your files. Default: `true`.

## Commands

Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
"hideComments.defaultEnabled": {
"type": "boolean",
"description": "Specify if the hide comments extension is by default enabled on start of the project.",
"default": false
},
"hideComments.cleanStart": {
"type": "boolean",
"description": "Specify if you want to reset to the default behaviour when you start a new Visual Studio Code instance.",
"default": true
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as vscode from 'vscode';

const CONFIG_SECTION = "hideComments";
const CONFIG_DEFAULT_ENABLED = "defaultEnabled";
const CONFIG_CLEAN_START = "cleanStart";
const CONFIG_TOKENS = "tokenColorCustomizations";

export async function activate({ subscriptions }: vscode.ExtensionContext) {
Expand All @@ -11,6 +12,7 @@ export async function activate({ subscriptions }: vscode.ExtensionContext) {

const extConfig = vscode.workspace.getConfiguration(CONFIG_SECTION);
const extDefaultEnabled = extConfig.get<boolean>(CONFIG_DEFAULT_ENABLED);
const extCleanStart = extConfig.get<boolean>(CONFIG_CLEAN_START);

const setComments = async (enabled: boolean) => {
if (config && colors) {
Expand Down Expand Up @@ -51,14 +53,18 @@ export async function activate({ subscriptions }: vscode.ExtensionContext) {

// Automatically start when the comments setting is not available
if (extDefaultEnabled && config && colors && !colors["comments"]) {
var choice = await vscode.window.showInformationMessage("Do you want to hide comments in this project?", "Yes", "No");
const choice = await vscode.window.showInformationMessage("Do you want to hide comments in this project?", "Yes", "No");
if (choice === "Yes") {
setComments(true);
} else {
setComments(false);
}
}

if (extCleanStart && config && colors && colors["comments"]) {
setComments(false);
}

const hideCommentsCmd = vscode.commands.registerCommand('hidecomments.hide', () => {
setComments(true);
});
Expand Down

0 comments on commit d432fa6

Please sign in to comment.