8000 rename now reports correct number of lines. (#345) · python-lsp/python-lsp-server@8a34aa2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8a34aa2

Browse files
Austin Binghamgatesn
Austin Bingham
authored andcommitted
rename now reports correct number of lines. (#345)
1 parent 1b176dd commit 8a34aa2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pyls/plugins/rope_rename.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Copyright 2017 Palantir Technologies, Inc.
22
import logging
33
import os
4-
import sys
54

65
from rope.base import libutils
76
from rope.refactor.rename import Rename
@@ -31,13 +30,19 @@ def pyls_rename(config, workspace, document, position, new_name):
3130
'uri': uris.uri_with(
3231
document.uri, path=os.path.join(workspace.root_path, change.resource.path)
3332
),
33+
'version': workspace.get_document(document.uri).version
3434
},
3535
'edits': [{
3636
'range': {
3737
'start': {'line': 0, 'character': 0},
38-
'end': {'line': sys.maxsize, 'character': 0},
38+
'end': {'line': _num_lines(change.resource), 'character': 0},
3939
},
4040
'newText': change.new_contents
4141
}]
4242
} for change in changeset.changes]
4343
}
44+
45+
46+
def _num_lines(resource):
47+
"Count the number of lines in a `File` resource."
48+
return len(resource.read().splitlines())

0 commit comments

Comments
 (0)
0