summaryrefslogtreecommitdiffhomepage
path: root/internal/tui
diff options
context:
space:
mode:
authorKujtim Hoxha <[email protected]>2025-04-12 18:45:36 +0200
committerKujtim Hoxha <[email protected]>2025-04-21 13:38:42 +0200
commitbd2ec29b65e430f83f430db5fdc424c7d631989d (patch)
tree0d7ee1a29a7932d54ffa1f247303568d85a3cf11 /internal/tui
parent0697dcc1d9c7330d8c9d8a2be0bb94b3d46c9345 (diff)
downloadopencode-bd2ec29b65e430f83f430db5fdc424c7d631989d.tar.gz
opencode-bd2ec29b65e430f83f430db5fdc424c7d631989d.zip
add initial git support
Diffstat (limited to 'internal/tui')
-rw-r--r--internal/tui/components/dialog/permission.go17
1 files changed, 11 insertions, 6 deletions
diff --git a/internal/tui/components/dialog/permission.go b/internal/tui/components/dialog/permission.go
index 088697d55..344310eb6 100644
--- a/internal/tui/components/dialog/permission.go
+++ b/internal/tui/components/dialog/permission.go
@@ -9,6 +9,7 @@ import (
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/glamour"
"github.com/charmbracelet/lipgloss"
+ "github.com/kujtimiihoxha/termai/internal/git"
"github.com/kujtimiihoxha/termai/internal/llm/tools"
"github.com/kujtimiihoxha/termai/internal/permission"
"github.com/kujtimiihoxha/termai/internal/tui/components/core"
@@ -234,7 +235,6 @@ func (p *permissionDialogCmp) render() string {
headerContent = lipgloss.NewStyle().Padding(0, 1).Render(lipgloss.JoinVertical(lipgloss.Left, headerParts...))
// Format the diff with colors
- formattedDiff := formatDiff(pr.Diff)
// Set up viewport for the diff content
p.contentViewPort.Width = p.width - 2 - 2
@@ -242,7 +242,11 @@ func (p *permissionDialogCmp) render() string {
// Calculate content height dynamically based on window size
maxContentHeight := p.height - lipgloss.Height(headerContent) - lipgloss.Height(form) - 2 - 2 - 1
p.contentViewPort.Height = maxContentHeight
- p.contentViewPort.SetContent(formattedDiff)
+ diff, err := git.FormatDiff(pr.Diff, p.contentViewPort.Width)
+ if err != nil {
+ diff = fmt.Sprintf("Error formatting diff: %v", err)
+ }
+ p.contentViewPort.SetContent(diff)
// Style the viewport
var contentBorder lipgloss.Border
@@ -281,16 +285,17 @@ func (p *permissionDialogCmp) render() string {
// Recreate header content with the updated headerParts
headerContent = lipgloss.NewStyle().Padding(0, 1).Render(lipgloss.JoinVertical(lipgloss.Left, headerParts...))
- // Format the diff with colors
- formattedDiff := formatDiff(pr.Content)
-
// Set up viewport for the content
p.contentViewPort.Width = p.width - 2 - 2
// Calculate content height dynamically based on window size
maxContentHeight := p.height - lipgloss.Height(headerContent) - lipgloss.Height(form) - 2 - 2 - 1
p.contentViewPort.Height = maxContentHeight
- p.contentViewPort.SetContent(formattedDiff)
+ diff, err := git.FormatDiff(pr.Diff, p.contentViewPort.Width)
+ if err != nil {
+ diff = fmt.Sprintf("Error formatting diff: %v", err)
+ }
+ p.contentViewPort.SetContent(diff)
// Style the viewport
var contentBorder lipgloss.Border