EditAttention: allow negatives (#476)

for #474
This commit is contained in:
Alex "mcmonkey" Goodwin
2024-08-16 18:56:03 -07:00
committed by GitHub
parent 7626d08c98
commit c73915e31e

View File

@@ -21,7 +21,6 @@ app.registerExtension({
const floatWeight = parseFloat(weight) const floatWeight = parseFloat(weight)
if (isNaN(floatWeight)) return weight if (isNaN(floatWeight)) return weight
const newWeight = floatWeight + delta const newWeight = floatWeight + delta
if (newWeight < 0) return '0'
return String(Number(newWeight.toFixed(10))) return String(Number(newWeight.toFixed(10)))
} }
@@ -143,7 +142,7 @@ app.registerExtension({
// Increment the weight // Increment the weight
const weightDelta = event.key === 'ArrowUp' ? delta : -delta const weightDelta = event.key === 'ArrowUp' ? delta : -delta
const updatedText = selectedText.replace( const updatedText = selectedText.replace(
/\((.*):(\d+(?:\.\d+)?)\)/, /\((.*):([+-]?\d+(?:\.\d+)?)\)/,
(match, text, weight) => { (match, text, weight) => {
weight = incrementWeight(weight, weightDelta) weight = incrementWeight(weight, weightDelta)
if (weight == 1) { if (weight == 1) {