@@ -11,7 +11,10 @@ import (
1111)
1212
1313func applyTextEdits(uri protocol.DocumentURI, edits []protocol.TextEdit) error {
14− path := uri.Path()
14+ path, err := uri.Path()
15+ if err != nil {
16+ return fmt.Errorf("invalid URI: %w", err)
17+ }
1518
1619 // Read the file content
1720 content, err := os.ReadFile(path)
@@ -148,7 +151,11 @@ func applyTextEdit(lines []string, edit protocol.TextEdit) ([]string, error) {
148151// applyDocumentChange applies a DocumentChange (create/rename/delete operations)
149152func applyDocumentChange(change protocol.DocumentChange) error {
150153 if change.CreateFile != nil {
151− path := change.CreateFile.URI.Path()
154+ path, err := change.CreateFile.URI.Path()
155+ if err != nil {
156+ return fmt.Errorf("invalid URI: %w", err)
157+ }
158+
152159 if change.CreateFile.Options != nil {
153160 if change.CreateFile.Options.Overwrite {
154161 // Proceed with overwrite
@@ -164,7 +171,11 @@ func applyDocumentChange(change protocol.DocumentChange) error {
164171 }
165172
166173 if change.DeleteFile != nil {
167− path := change.DeleteFile.URI.Path()
174+ path, err := change.DeleteFile.URI.Path()
175+ if err != nil {
176+ return fmt.Errorf("invalid URI: %w", err)
177+ }
178+
168179 if change.DeleteFile.Options != nil && change.DeleteFile.Options.Recursive {
169180 if err := os.RemoveAll(path); err != nil {
170181 return fmt.Errorf("failed to delete directory recursively: %w", err)
@@ -177,8 +188,19 @@ func applyDocumentChange(change protocol.DocumentChange) error {
177188 }
178189
179190 if change.RenameFile != nil {
180− oldPath := change.RenameFile.OldURI.Path()
181− newPath := change.RenameFile.NewURI.Path()
191+ var newPath, oldPath string
192+ var err error
193+
194+ oldPath, err = change.RenameFile.OldURI.Path()
195+ if err != nil {
196+ return err
197+ }
198+
199+ newPath, err = change.RenameFile.NewURI.Path()
200+ if err != nil {
201+ return err
202+ }
203+
182204 if change.RenameFile.Options != nil {
183205 if !change.RenameFile.Options.Overwrite {
184206 if _, err := os.Stat(newPath); err == nil {