8000 Fixes off by one for code action fixes · kstrauser/python-lsp-ruff@07fa9ac · GitHub
[go: up one dir, main page]

Skip to content

Commit 07fa9ac

Browse files
tzacharjhossbach
authored andcommitted
Fixes off by one for code action fixes
It seems that applying code fixes in neovim is off by one column. For example, running sort imports on the following code: ```python import json import date date ``` results in the following: ```python iimport json import date ate ``` applying the this patch seems to solve the issue
1 parent 072b23e commit 07fa9ac

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pylsp_ruff/plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,11 +334,11 @@ def create_text_edits(fix: RuffFix) -> List[TextEdit]:
334334
range = Range(
335335
start=Position(
336336
line=edit.location.row - 1,
337-
character=edit.location.column, # yes, no -1
337+
character=edit.location.column - 1,
338338
),
339339
end=Position(
340340
line=edit.end_location.row - 1,
341-
character=edit.end_location.column, # yes, no -1
341+
character=edit.end_location.column - 1,
342342
),
343343
)
344344
edits.append(TextEdit(range=range, new_text=edit.content))

0 commit comments

Comments
 (0)
0