diff --git a/extensions/void/src/ApprovalCodeLensProvider.ts b/extensions/void/src/ApprovalCodeLensProvider.ts index b6c6fa12..747e2906 100644 --- a/extensions/void/src/ApprovalCodeLensProvider.ts +++ b/extensions/void/src/ApprovalCodeLensProvider.ts @@ -51,9 +51,7 @@ export class ApprovalCodeLensProvider implements vscode.CodeLensProvider { constructor() { // this acts as a useEffect. Every time text changes, clear the diffs in this editor - // TODO ideally we wouldn't clear the diffs, we would just re-draw them and update their ranges vscode.workspace.onDidChangeTextDocument((e) => { - // TODO we need to move all the codelenses and ranges below this one up/down depending on the number of newlines added - this is a known bug const editor = vscode.window.activeTextEditor if (!editor) return @@ -83,6 +81,10 @@ export class ApprovalCodeLensProvider implements vscode.CodeLensProvider { const diffs: DiffType[] = [] for (let suggestedEdit of suggestedEdits) { + // TODO we need to account for the case when startLine > endLine (pure inserts) + if (suggestedEdit.startLine > suggestedEdit.endLine) + continue + const selectedRange = new vscode.Range(suggestedEdit.startLine, 0, suggestedEdit.endLine, Number.MAX_SAFE_INTEGER) // if any other codelens intersects with the selection, ignore this edit @@ -126,9 +128,6 @@ export class ApprovalCodeLensProvider implements vscode.CodeLensProvider { // 3. apply green highlighting for each (+) diff editor.setDecorations(greenDecoration, this._diffsOfDocument[docUriStr].map(diff => diff.range)) - // 4. TODO create a red placeholder for each (-) diff - // TODO... - // recompute _computedLensesOfDocument (can optimize this later) this._computedLensesOfDocument[docUriStr] = this._diffsOfDocument[docUriStr].flatMap(diff => diff.lenses)