python-lsp / python-lsp-server

Fork of the python-language-server project, maintained by the Spyder IDE team and the community
MIT License
1.76k stars 186 forks source link

textDocument/rename reports positions outside of the document #413

Closed davschul closed 9 months ago

davschul commented 11 months ago

When having a document that ends without a trailing newline 'textDocument/rename' reports a document change that contains a position outside of the document as the end position. For example a document just containing of: foo=12

Ttriggering a rename on the beginning of foo with the replacement bar results in the following edits: "edits": [ { "newText": "bar = 12", "range": { "end": { "character": 0, "line": 1 }, "start": { "character": 0, "line": 0 } } } ],

But the document just has one line, line 1 is out of the document scope. Expected would be "end": { "character": 6, "line": 0 }

ccordoba12 commented 11 months ago

Thanks for reporting @davschul. Could you submit a pull request to fix this?