mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
feat: Revert regex interpretation to require // delimiters and update en.json placeholder
This commit is contained in:
@@ -1339,7 +1339,7 @@
|
||||
"enter-width-pixels": "Enter width in pixels",
|
||||
"enter-command": "Enter command to execute (app or custom script)",
|
||||
"command-example": "echo \"Hello World\"",
|
||||
"enter-text-to-collapse": "Enter text or regex to collapse (e.g., 'nothing is playing' or '^nothing is playing')",
|
||||
"enter-text-to-collapse": "e.g., 'nothing is playing'. Use /regex/ for patterns.",
|
||||
"search-wallpapers": "Type to filter wallpapers...",
|
||||
"search-launcher": "Search entries... or use > for commands",
|
||||
"search": "Search...",
|
||||
|
||||
@@ -104,11 +104,18 @@ Item {
|
||||
var shouldCollapse = false
|
||||
|
||||
if (textCollapse && textCollapse.length > 0) {
|
||||
try {
|
||||
var regex = new RegExp(textCollapse)
|
||||
shouldCollapse = regex.test(lineStr)
|
||||
} catch (e) {
|
||||
// If it's not a valid regex, treat it as a plain string
|
||||
if (textCollapse.startsWith("/") && textCollapse.endsWith("/") && textCollapse.length > 1) {
|
||||
// Treat as regex
|
||||
var pattern = textCollapse.substring(1, textCollapse.length - 1)
|
||||
try {
|
||||
var regex = new RegExp(pattern)
|
||||
shouldCollapse = regex.test(lineStr)
|
||||
} catch (e) {
|
||||
Logger.w("CustomButton", `Invalid regex for textCollapse: ${textCollapse} - ${e.message}`)
|
||||
shouldCollapse = (textCollapse === lineStr) // Fallback to exact match on invalid regex
|
||||
}
|
||||
} else {
|
||||
// Treat as plain string
|
||||
shouldCollapse = (textCollapse === lineStr)
|
||||
}
|
||||
}
|
||||
@@ -131,11 +138,18 @@ Item {
|
||||
var shouldCollapse = false
|
||||
|
||||
if (textCollapse && textCollapse.length > 0) {
|
||||
try {
|
||||
var regex = new RegExp(textCollapse)
|
||||
shouldCollapse = regex.test(out)
|
||||
} catch (e) {
|
||||
// If it's not a valid regex, treat it as a plain string
|
||||
if (textCollapse.startsWith("/") && textCollapse.endsWith("/") && textCollapse.length > 1) {
|
||||
// Treat as regex
|
||||
var pattern = textCollapse.substring(1, textCollapse.length - 1)
|
||||
try {
|
||||
var regex = new RegExp(pattern)
|
||||
shouldCollapse = regex.test(out)
|
||||
} catch (e) {
|
||||
Logger.w("CustomButton", `Invalid regex for textCollapse: ${textCollapse} - ${e.message}`)
|
||||
shouldCollapse = (textCollapse === out) // Fallback to exact match on invalid regex
|
||||
}
|
||||
} else {
|
||||
// Treat as plain string
|
||||
shouldCollapse = (textCollapse === out)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user