From bf0b23b264a11db14a8e6dd2f78ec2a46211e7d2 Mon Sep 17 00:00:00 2001 From: Anton Bachin Date: Wed, 19 Apr 2023 12:15:21 +0300 Subject: [PATCH] Show the combo counter after a threshold --- package.json | 6 ++++++ src/combo/combo-plugin.ts | 1 + src/combo/config.ts | 1 + src/combo/editor-combo-meter.ts | 5 +++-- src/config/configuration-keys.ts | 1 + 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d7937de..2279207 100644 --- a/package.json +++ b/package.json @@ -141,6 +141,12 @@ "minimum": 0, "description": "Control the size of the Combo Meter text" }, + "powermode.combo.counterThreshold": { + "type": "number", + "default": 1, + "minimum": 1, + "description": "The combo number needed to show the counter." + }, "powermode.combo.timerEnabled": { "type": "string", "default": "default", diff --git a/src/combo/combo-plugin.ts b/src/combo/combo-plugin.ts index d354554..33c0d13 100644 --- a/src/combo/combo-plugin.ts +++ b/src/combo/combo-plugin.ts @@ -19,6 +19,7 @@ export class ComboPlugin implements Plugin { enableComboTimer: comboFeatureConfigToBoolean(getConfigValue("combo.timerEnabled", config)), enableComboCounter: comboFeatureConfigToBoolean(getConfigValue("combo.counterEnabled", config)), comboCounterSize: getConfigValue("combo.counterSize", config), + comboCounterThreshold: getConfigValue("combo.counterThreshold", config), } if (this.config.comboLocation !== oldLocation) { diff --git a/src/combo/config.ts b/src/combo/config.ts index f16c30f..42a3728 100644 --- a/src/combo/config.ts +++ b/src/combo/config.ts @@ -9,4 +9,5 @@ export interface ComboPluginConfig { enableComboTimer: boolean; enableComboCounter: boolean; comboCounterSize: number; + comboCounterThreshold: number; } diff --git a/src/combo/editor-combo-meter.ts b/src/combo/editor-combo-meter.ts index 927635d..6ca42fb 100644 --- a/src/combo/editor-combo-meter.ts +++ b/src/combo/editor-combo-meter.ts @@ -2,7 +2,7 @@ import * as vscode from 'vscode'; import { Plugin, PowermodeChangeTextDocumentEventData } from '../plugin'; import { ComboPluginConfig } from './config'; -export type EditorComboMeterConfig = Pick; +export type EditorComboMeterConfig = Pick; export class EditorComboMeter implements Plugin { @@ -135,8 +135,9 @@ export class EditorComboMeter implements Plugin { } const firstVisibleRange = editor.visibleRanges.sort().find(range => !range.isEmpty); + const comboThreshold = this.config?.comboCounterThreshold || 1; - if (!firstVisibleRange || this.combo < 1) { + if (!firstVisibleRange || this.combo < comboThreshold) { this.removeDecorations(); return; } diff --git a/src/config/configuration-keys.ts b/src/config/configuration-keys.ts index 0f7784f..29224ce 100644 --- a/src/config/configuration-keys.ts +++ b/src/config/configuration-keys.ts @@ -6,6 +6,7 @@ export const ConfigurationKeys = [ "combo.timeout", "combo.counterEnabled", "combo.counterSize", + "combo.counterThreshold", "combo.timerEnabled", "shake.enabled", "shake.intensity",