diff options
| author | Kujtim Hoxha <[email protected]> | 2025-04-03 17:36:40 +0200 |
|---|---|---|
| committer | Kujtim Hoxha <[email protected]> | 2025-04-03 17:38:28 +0200 |
| commit | 795b3692197acf75ff13ed8a14c9a11d4b32ec5f (patch) | |
| tree | 186dfea8eb2aa1f87a9960f415ac852f3768982e /internal/lsp | |
| parent | cfdd687216799cb5b47f099f1e7cd5dd16b3bdd0 (diff) | |
| download | opencode-795b3692197acf75ff13ed8a14c9a11d4b32ec5f.tar.gz opencode-795b3692197acf75ff13ed8a14c9a11d4b32ec5f.zip | |
small fixes
Diffstat (limited to 'internal/lsp')
| -rw-r--r-- | internal/lsp/util/edit.go | 8 | ||||
| -rw-r--r-- | internal/lsp/watcher/watcher.go | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/internal/lsp/util/edit.go b/internal/lsp/util/edit.go index 180429ce5..3b94fb39f 100644 --- a/internal/lsp/util/edit.go +++ b/internal/lsp/util/edit.go @@ -34,9 +34,9 @@ func applyTextEdits(uri protocol.DocumentUri, edits []protocol.TextEdit) error { lines := strings.Split(string(content), lineEnding) // Check for overlapping edits - for i := 0; i < len(edits); i++ { + for i, edit1 := range edits { for j := i + 1; j < len(edits); j++ { - if rangesOverlap(edits[i].Range, edits[j].Range) { + if rangesOverlap(edit1.Range, edits[j].Range) { return fmt.Errorf("overlapping edits detected between edit %d and %d", i, j) } } @@ -54,7 +54,7 @@ func applyTextEdits(uri protocol.DocumentUri, edits []protocol.TextEdit) error { // Apply each edit for _, edit := range sortedEdits { - newLines, err := applyTextEdit(lines, edit, lineEnding) + newLines, err := applyTextEdit(lines, edit) if err != nil { return fmt.Errorf("failed to apply edit: %w", err) } @@ -82,7 +82,7 @@ func applyTextEdits(uri protocol.DocumentUri, edits []protocol.TextEdit) error { return nil } -func applyTextEdit(lines []string, edit protocol.TextEdit, lineEnding string) ([]string, error) { +func applyTextEdit(lines []string, edit protocol.TextEdit) ([]string, error) { startLine := int(edit.Range.Start.Line) endLine := int(edit.Range.End.Line) startChar := int(edit.Range.Start.Character) diff --git a/internal/lsp/watcher/watcher.go b/internal/lsp/watcher/watcher.go index a9d057c71..7a6eaacc5 100644 --- a/internal/lsp/watcher/watcher.go +++ b/internal/lsp/watcher/watcher.go @@ -347,7 +347,7 @@ func matchesSimpleGlob(pattern, path string) bool { // Otherwise, check if any path component matches pathComponents := strings.Split(path, "/") - for i := 0; i < len(pathComponents); i++ { + for i := range pathComponents { subPath := strings.Join(pathComponents[i:], "/") if strings.HasSuffix(subPath, rest) { return true |
