diff options
author | Nate Sesti <sestinj@gmail.com> | 2023-06-15 09:09:12 -0700 |
---|---|---|
committer | Nate Sesti <sestinj@gmail.com> | 2023-06-15 09:09:12 -0700 |
commit | 7a6c86453f0451b30cb14946c5a8171d79623e60 (patch) | |
tree | 75a4cc40743706b22f3a45e04eec67810bb58d3a | |
parent | 0c33de59e472b53ea2a4d9aadde391b5b10343d4 (diff) | |
download | sncontinue-7a6c86453f0451b30cb14946c5a8171d79623e60.tar.gz sncontinue-7a6c86453f0451b30cb14946c5a8171d79623e60.tar.bz2 sncontinue-7a6c86453f0451b30cb14946c5a8171d79623e60.zip |
highlight all lines at once
-rw-r--r-- | continuedev/src/continuedev/steps/core/core.py | 24 |
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) |