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

New settings v0.2.1 #83

Merged
merged 2 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

<br/>

> ### v0.2.0
> ### v0.2.1:
- feat: add option to disable the default configuration order.

> ### v0.2.0:
- feat: add language-specific settings [#27](https://github.com/moalamri/vscode-inline-fold/issues/27) by [@Zer0xTJ](https://github.com/Zer0xTJ)
- feat: add astro as a supported language by [@Aunali321](https://github.com/Aunali321)

Expand Down
27 changes: 17 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Inline fold",
"description": "A custom decorator that \"fold\" matching content in single line",
"icon": "res/icon.png",
"version": "0.2.0",
"version": "0.2.1",
"publisher": "moalamri",
"homepage": "https://github.com/moalamri/vscode-inline-fold",
"bugs": "https://github.com/moalamri/vscode-inline-fold/issues",
Expand Down Expand Up @@ -45,9 +45,16 @@
"description": "Set the default state of inline fold when opening a file",
"default": true
},
"inlineFold.useGlobal": {
"type": "boolean",
"order": 1,
"scope": "language-overridable",
"description": "Change the order to use global configuration before language-specific",
"default": false
},
"inlineFold.supportedLanguages": {
"type": "array",
"order": 1,
"order": 2,
"description": "Supported languages",
"items": {
"type": "string",
Expand Down Expand Up @@ -75,7 +82,7 @@
},
"inlineFold.regex": {
"type": "string",
"order": 2,
"order": 3,
"description": "Regex to match",
"scope": "language-overridable",
"default": "(class|className)=(({(`|))|(['\"`]))(.*?)(\\2|(\\4)})",
Expand All @@ -87,7 +94,7 @@
},
"inlineFold.regexFlags": {
"type": "string",
"order": 3,
"order": 4,
"scope": "language-overridable",
"description": "Regex flags",
"default": "g",
Expand All @@ -98,7 +105,7 @@
},
"inlineFold.regexGroup": {
"type": "string",
"order": 4,
"order": 5,
"scope": "language-overridable",
"description": "Regex capture group number for content that will be folded",
"default": "6",
Expand All @@ -113,7 +120,7 @@
},
"inlineFold.maskChar": {
"type": "string",
"order": 5,
"order": 6,
"scope": "language-overridable",
"description": "The mask that covers the folded text",
"default": "◦◦◦",
Expand All @@ -125,7 +132,7 @@
},
"inlineFold.maskColor": {
"type": "string",
"order": 6,
"order": 7,
"scope": "language-overridable",
"description": "The color of the covering mask in hex",
"default": "#68D7AC",
Expand All @@ -136,7 +143,7 @@
},
"inlineFold.unfoldedOpacity": {
"type": "number",
"order": 7,
"order": 8,
"scope": "language-overridable",
"description": "The opacity of the unfolded text (from 0 to 1)",
"default": 0.7,
Expand All @@ -156,7 +163,7 @@
},
"inlineFold.after": {
"type": "string",
"order": 8,
"order": 9,
"scope": "language-overridable",
"description": "(Optional) Add any text/character to be appended to the folded text",
"default": "",
Expand All @@ -169,7 +176,7 @@
"inlineFold.unfoldOnLineSelect": {
"type": "boolean",
"scope": "language-overridable",
"order": 9,
"order": 10,
"description": "(Optional) unfold the line when any part of the line is selected",
"default": false
}
Expand Down
3 changes: 2 additions & 1 deletion src/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ export enum Settings {
unfoldedOpacity = "unfoldedOpacity",
after = "after",
supportedLanguages = "supportedLanguages",
unfoldOnLineSelect = "unfoldOnLineSelect"
unfoldOnLineSelect = "unfoldOnLineSelect",
useGlobal = "useGlobal"
}
6 changes: 5 additions & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ class ExtensionSettings {
*/
public Get<T>(_section: Settings): T {
// Try to get language scope configuration, otherwise fallback to global configuration
const getGlobal = this.configs.get(Settings.useGlobal)
if (getGlobal) {
return this.configs.get<T>(_section) as T
}
return (this.getPerLanguage<T>(_section) as T) ?? (this.configs.get<T>(_section) as T);
}

Expand All @@ -79,7 +83,7 @@ class ExtensionSettings {
return RegExp(this.Get<RegExp>(Settings.regex), this.Get<string>(Settings.regexFlags));
}

constructor() {}
constructor () { }
}

// Yes, a singleton :0
Expand Down