summaryrefslogtreecommitdiffhomepage
path: root/packages/tui/internal/layout
diff options
context:
space:
mode:
authorMatias Insaurralde <[email protected]>2025-07-16 06:20:25 -0300
committerGitHub <[email protected]>2025-07-16 04:20:25 -0500
commite89972a396c5b71b27b54c841fe26a2e9e53f5be (patch)
tree8883b42c17c79f77b699d372394df5fcbf951369 /packages/tui/internal/layout
parentc3c647a21a4a04cb80dd90cbc0d78b180584e096 (diff)
downloadopencode-e89972a396c5b71b27b54c841fe26a2e9e53f5be.tar.gz
opencode-e89972a396c5b71b27b54c841fe26a2e9e53f5be.zip
perf: move ANSI regex compilations to package level (#1040)
Signed-off-by: Matías Insaurralde <[email protected]>
Diffstat (limited to 'packages/tui/internal/layout')
-rw-r--r--packages/tui/internal/layout/overlay.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/packages/tui/internal/layout/overlay.go b/packages/tui/internal/layout/overlay.go
index 48064c91a..08016e31c 100644
--- a/packages/tui/internal/layout/overlay.go
+++ b/packages/tui/internal/layout/overlay.go
@@ -15,6 +15,11 @@ import (
"github.com/sst/opencode/internal/util"
)
+var (
+ // ANSI escape sequence regex
+ ansiRegex = regexp.MustCompile(`\x1b\[[0-9;]*m`)
+)
+
// Split a string into lines, additionally returning the size of the widest line.
func getLines(s string) (lines []string, widest int) {
lines = strings.Split(s, "\n")
@@ -272,9 +277,6 @@ func combineStyles(bgStyle ansiStyle, fgColor *compat.AdaptiveColor) string {
// getStyleAtPosition extracts the active ANSI style at a given visual position
func getStyleAtPosition(s string, targetPos int) ansiStyle {
- // ANSI escape sequence regex
- ansiRegex := regexp.MustCompile(`\x1b\[[0-9;]*m`)
-
visualPos := 0
currentStyle := ansiStyle{}