diff options
| author | Kujtim Hoxha <[email protected]> | 2025-04-04 14:36:57 +0200 |
|---|---|---|
| committer | Kujtim Hoxha <[email protected]> | 2025-04-04 14:36:57 +0200 |
| commit | c185dc84d6810ee6a56b656640c213f65150d30f (patch) | |
| tree | bd6f3689b66941b5a5d9d1e20e3e525f5f62427d /internal/llm/tools/edit.go | |
| parent | 6bb1c84f7f7f0430f2808d50c533e923aae4c787 (diff) | |
| download | opencode-c185dc84d6810ee6a56b656640c213f65150d30f.tar.gz opencode-c185dc84d6810ee6a56b656640c213f65150d30f.zip | |
Enhance UI feedback and improve file diff visualization
- Improve diff display in permission dialogs with better formatting
- Add visual indicators for focus changes in permission dialogs
- Increase diagnostics timeout from 5 to 10 seconds
- Fix write tool to show proper diffs for existing files
- Update status component to properly handle messages
🤖 Generated with termai
Co-Authored-By: termai <[email protected]>
Diffstat (limited to 'internal/llm/tools/edit.go')
| -rw-r--r-- | internal/llm/tools/edit.go | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/internal/llm/tools/edit.go b/internal/llm/tools/edit.go index f12a1eb21..394ce13b9 100644 --- a/internal/llm/tools/edit.go +++ b/internal/llm/tools/edit.go @@ -303,23 +303,46 @@ func GenerateDiff(oldContent, newContent string) string { diffs = dmp.DiffCharsToLines(diffs, dmpStrings) diffs = dmp.DiffCleanupSemantic(diffs) buff := strings.Builder{} + + // Add a header to make the diff more readable + buff.WriteString("Changes:\n") + for _, diff := range diffs { text := diff.Text switch diff.Type { case diffmatchpatch.DiffInsert: - for line := range strings.SplitSeq(text, "\n") { + for _, line := range strings.Split(text, "\n") { + if line == "" { + continue + } _, _ = buff.WriteString("+ " + line + "\n") } case diffmatchpatch.DiffDelete: - for line := range strings.SplitSeq(text, "\n") { + for _, line := range strings.Split(text, "\n") { + if line == "" { + continue + } _, _ = buff.WriteString("- " + line + "\n") } case diffmatchpatch.DiffEqual: - if len(text) > 40 { - _, _ = buff.WriteString(" " + text[:20] + "..." + text[len(text)-20:] + "\n") + // Only show a small context for unchanged text + lines := strings.Split(text, "\n") + if len(lines) > 3 { + // Show only first and last line of context with a separator + if lines[0] != "" { + _, _ = buff.WriteString(" " + lines[0] + "\n") + } + _, _ = buff.WriteString(" ...\n") + if lines[len(lines)-1] != "" { + _, _ = buff.WriteString(" " + lines[len(lines)-1] + "\n") + } } else { - for line := range strings.SplitSeq(text, "\n") { + // Show all lines for small contexts + for _, line := range lines { + if line == "" { + continue + } _, _ = buff.WriteString(" " + line + "\n") } } |
