Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: minor improvements, close #86 #87

Merged
merged 1 commit into from
Apr 21, 2023
Merged
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
29 changes: 10 additions & 19 deletions lib/autocloaking.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,22 @@ const run = function (context) {
}

function hideValues () {
const config = vscode.workspace.getConfiguration().inspect(section()).globalValue
const config = vscode.workspace.getConfiguration().inspect(section()).globalValue || {}

try {
const rules = config ? config.textMateRules : []
const newRules = []

if (rules) {
for (const rule of rules) {
if (rule.scope === scope) {
// in order to prevent double adding. new rule is added below
} else {
newRules.push(rule) // preserve any other rules
}
}
}
const newRule = {
const rules = Array.isArray(config?.textMateRules) ? config.textMateRules : []

// in order to prevent double adding
const newRules = rules.filter((rule) => rule?.scope !== scope)
// add new rule
newRules.push({
scope,
settings: { foreground: '#FF000000' } // set transparency to 0
}
newRules.push(newRule) // add new rule
})

// Update the textMateRules without changing the other tokenColorCustomization values (issue #79)
const value = config
value.textMateRules = newRules
vscode.workspace.getConfiguration().update(section(), value, vscode.ConfigurationTarget.Global)
config.textMateRules = newRules
vscode.workspace.getConfiguration().update(section(), config, vscode.ConfigurationTarget.Global)
} catch (e) {
console.log(e)
}
Expand Down