Skip to content

Commit bf41811

Browse files
committed
Update deleted suffix in suggestion
1 parent 6f0ad43 commit bf41811

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

Tool/Sources/SharedUIComponents/AsyncCodeBlock.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,12 @@ extension AsyncCodeBlock {
282282
if lastLineIndex >= 0 {
283283
if let line = diffResult.line(at: lastLineIndex, in: \.oldSnippet),
284284
case let .mutated(changes) = line.diff,
285-
!changes.isEmpty
285+
changes.count == 1,
286+
let change = changes.last,
287+
change.offset + change.element.count == line.text.count
286288
{
287289
let lastLine = highlightedCode[lastLineIndex]
288-
let removedSuffix = line.text.suffix(max(
289-
0,
290-
line.text.count - lastLine.string.count
291-
))
292-
lastLine.append(.init(string: String(removedSuffix), attributes: [
290+
lastLine.append(.init(string: String(change.element), attributes: [
293291
.foregroundColor: NSColor.systemRed.withAlphaComponent(0.4),
294292
.backgroundColor: NSColor.systemRed.withAlphaComponent(0.1),
295293
]))

0 commit comments

Comments
 (0)