summaryrefslogtreecommitdiff
path: root/continuedev
diff options
context:
space:
mode:
authorNate Sesti <sestinj@gmail.com>2023-06-15 09:09:12 -0700
committerNate Sesti <sestinj@gmail.com>2023-06-15 09:09:12 -0700
commit6d29f8b0f8bca4d01ecbbf9e5d949503c127c3f4 (patch)
tree11d549d632aedc6148b79af7110869bd8bc15732 /continuedev
parent1b70043e8f20c01627ad47b10e71570202e80d77 (diff)
downloadsncontinue-6d29f8b0f8bca4d01ecbbf9e5d949503c127c3f4.tar.gz
sncontinue-6d29f8b0f8bca4d01ecbbf9e5d949503c127c3f4.tar.bz2
sncontinue-6d29f8b0f8bca4d01ecbbf9e5d949503c127c3f4.zip
highlight all lines at once
Diffstat (limited to 'continuedev')
-rw-r--r--continuedev/src/continuedev/steps/core/core.py24
1 files changed, 20 insertions, 4 deletions
diff --git a/continuedev/src/continuedev/steps/core/core.py b/continuedev/src/continuedev/steps/core/core.py
index eb367ca9..aee5bc1d 100644
--- a/continuedev/src/continuedev/steps/core/core.py
+++ b/continuedev/src/continuedev/steps/core/core.py
@@ -198,13 +198,13 @@ class DefaultModelEditCodeStep(Step):
diff = list(difflib.ndiff(rif.contents.splitlines(
keepends=True), completion.splitlines(keepends=True)))
- lines_to_highlight = []
+ lines_to_highlight = set()
index = 0
for line in diff:
if line.startswith("-"):
pass
elif line.startswith("+"):
- lines_to_highlight.append(index + rif.range.start.line)
+ lines_to_highlight.add(index + rif.range.start.line)
index += 1
elif line.startswith(" "):
index += 1
@@ -215,8 +215,24 @@ class DefaultModelEditCodeStep(Step):
replacement=completion
))
- for line in lines_to_highlight:
- await sdk.ide.highlightCode(RangeInFile(filepath=rif.filepath, range=Range.from_shorthand(line, 0, line, 0)))
+ current_hl_start = None
+ last_hl = None
+ rifs_to_highlight = []
+ for line in sorted(list(lines_to_highlight)):
+ if current_hl_start is None:
+ current_hl_start = line
+ elif line != last_hl + 1:
+ rifs_to_highlight.append(RangeInFile(
+ filepath=rif.filepath, range=Range.from_shorthand(current_hl_start, 0, last_hl, 0)))
+ current_hl_start = line
+ last_hl = line
+
+ if current_hl_start is not None:
+ rifs_to_highlight.append(RangeInFile(
+ filepath=rif.filepath, range=Range.from_shorthand(current_hl_start, 0, last_hl, 0)))
+
+ for rif_to_hl in rifs_to_highlight:
+ await sdk.ide.highlightCode(rif_to_hl)
await sdk.ide.saveFile(rif.filepath)