Просмотр исходного кода

Revert "fix: prevent sparse spacing in hyphenated words (#1102)"

This reverts commit 2b44dbdbf105f1c5d1cd34b7ae86925ff41e4c79.
Dax Raad 7 месяцев назад
Родитель
Сommit
87d21ebf2b

+ 4 - 10
packages/tui/internal/components/chat/message.go

@@ -196,8 +196,6 @@ func renderText(
 	case opencode.UserMessage:
 		ts = time.UnixMilli(int64(casted.Time.Created))
 		base := styles.NewStyle().Foreground(t.Text()).Background(backgroundColor)
-
-		// Process @ mentions and styling with hyphen preservation
 		words := strings.Fields(text)
 		for i, word := range words {
 			if strings.HasPrefix(word, "@") {
@@ -206,14 +204,9 @@ func renderText(
 				words[i] = base.Render(word + " ")
 			}
 		}
-		styledText := strings.Join(words, "")
-
-		// Apply word wrapping with hyphen preservation
-		frameSize := util.GetMessageContainerFrame()
-		wrappedText := util.ProcessTextWithHyphens(styledText, func(t string) string {
-			return ansi.WordwrapWc(t, width-frameSize, " ")
-		})
-		content = base.Width(width - frameSize).Render(wrappedText)
+		text = strings.Join(words, "")
+		text = ansi.WordwrapWc(text, width-6, " -")
+		content = base.Width(width - 6).Render(text)
 	}
 
 	timestamp := ts.
@@ -715,4 +708,5 @@ func renderDiagnostics(
 	// if !ok {
 	// 	return ""
 	// }
+
 }

+ 0 - 4
packages/tui/internal/components/textarea/textarea.go

@@ -2051,10 +2051,6 @@ func wrapInterfaces(content []any, width int) [][]any {
 			if unicode.IsSpace(r) {
 				isSpace = true
 			}
-			// Use hyphen-aware word boundary detection
-			if r == '-' {
-				isSpace = false
-			}
 			itemW = rw.RuneWidth(r)
 		} else if att, ok := item.(*Attachment); ok {
 			itemW = uniseg.StringWidth(att.Display)

+ 3 - 9
packages/tui/internal/util/file.go

@@ -83,17 +83,11 @@ func Extension(path string) string {
 }
 
 func ToMarkdown(content string, width int, backgroundColor compat.AdaptiveColor) string {
-	renderWidth := width - GetMarkdownContainerFrame()
-	r := styles.GetMarkdownRenderer(renderWidth, backgroundColor)
+	r := styles.GetMarkdownRenderer(width-6, backgroundColor)
 	content = strings.ReplaceAll(content, RootPath+"/", "")
-
-	// Apply hyphen preservation during markdown rendering
-	rendered := ProcessTextWithHyphens(content, func(t string) string {
-		result, _ := r.Render(t)
-		return result
-	})
+	rendered, _ := r.Render(content)
 	lines := strings.Split(rendered, "\n")
-	// Clean up empty lines at start/end
+
 	if len(lines) > 0 {
 		firstLine := lines[0]
 		cleaned := ansi.Strip(firstLine)