Skip to content

Commit 0fe6cf6

Browse files
authored
Merge branch 'develop' into docstring-hook
2 parents 0a3113e + 04fa3e5 commit 0fe6cf6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pylsp/workspace.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,8 @@ def apply_change(self, change):
460460
end_col = change_range["end"]["character"]
461461

462462
# Check for an edit occuring at the very end of the file
463-
if start_line == len(self.lines):
463+
lines = self.lines
464+
if start_line == len(lines):
464465
self._source = self.source + text
465466
return
466467

@@ -469,7 +470,7 @@ def apply_change(self, change):
469470
# Iterate over the existing document until we hit the edit range,
470471
# at which point we write the new text, then loop until we hit
471472
# the end of the range and continue writing.
472-
for i, line in enumerate(self.lines):
473+
for i, line in enumerate(lines):
473474
if i < start_line:
474475
new.write(line)
475476
continue
@@ -493,10 +494,11 @@ def offset_at_position(self, position):
493494

494495
def word_at_position(self, position):
495496
"""Get the word under the cursor returning the start and end positions."""
496-
if position["line"] >= len(self.lines):
497+
lines = self.lines
498+
if position["line"] >= len(lines):
497499
return ""
498500

499-
line = self.lines[position["line"]]
501+
line = lines[position["line"]]
500502
i = position["character"]
501503
# Split word in two
502504
start = line[:i]

0 commit comments

Comments
 (0)