Skip to content

Commit

Permalink
[autofix.ci] apply automated fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
autofix-ci[bot] authored Jan 16, 2025
1 parent 7f88130 commit 3bd2214
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 42 deletions.
78 changes: 39 additions & 39 deletions clients/tabby-agent/src/codeLens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const changesPreviewLineType = {
deleted: "deleted" as ChangesPreviewLineType,
};

const logger = getLogger('CodeLensProvider');
const logger = getLogger("CodeLensProvider");

export class CodeLensProvider implements Feature {
constructor(private readonly documents: TextDocuments<TextDocument>) {}
Expand Down Expand Up @@ -64,7 +64,7 @@ export class CodeLensProvider implements Feature {
let previewBlockMarkers = "";
const originLines: string[] = [];
const editLines: string[] = [];
const editCodeLenses: CodeLens[] = []
const editCodeLenses: CodeLens[] = [];
for (let line = textDocument.lineCount - 1; line >= 0; line = line - 1) {
if (token.isCancellationRequested) {
return null;
Expand Down Expand Up @@ -174,9 +174,9 @@ export class CodeLensProvider implements Feature {
line: changesPreviewLineType.waiting,
},
};
originLines.unshift(text)
editLines.unshift(text)
editCodeLenses.unshift(codeLens)
originLines.unshift(text);
editLines.unshift(text);
editCodeLenses.unshift(codeLens);
break;
case "|":
codeLens = {
Expand All @@ -186,8 +186,8 @@ export class CodeLensProvider implements Feature {
line: changesPreviewLineType.inProgress,
},
};
editLines.unshift(text)
editCodeLenses.unshift(codeLens)
editLines.unshift(text);
editCodeLenses.unshift(codeLens);
break;
case "=":
codeLens = {
Expand All @@ -197,9 +197,9 @@ export class CodeLensProvider implements Feature {
line: changesPreviewLineType.unchanged,
},
};
originLines.unshift(text)
editLines.unshift(text)
editCodeLenses.unshift(codeLens)
originLines.unshift(text);
editLines.unshift(text);
editCodeLenses.unshift(codeLens);
break;
case "+":
codeLens = {
Expand All @@ -209,8 +209,8 @@ export class CodeLensProvider implements Feature {
line: changesPreviewLineType.inserted,
},
};
editLines.unshift(text)
editCodeLenses.unshift(codeLens)
editLines.unshift(text);
editCodeLenses.unshift(codeLens);
break;
case "-":
codeLens = {
Expand All @@ -220,7 +220,7 @@ export class CodeLensProvider implements Feature {
line: changesPreviewLineType.deleted,
},
};
originLines.unshift(text)
originLines.unshift(text);
break;
default:
break;
Expand All @@ -238,9 +238,9 @@ export class CodeLensProvider implements Feature {
}
}
}
const charDecorationLenses = this.getCharDiffDecoration(originLines, editLines, editCodeLenses)
codeLenses.push(...charDecorationLenses)
logger.debug(`codeLenses: ${JSON.stringify(codeLenses)}`)
const charDecorationLenses = this.getCharDiffDecoration(originLines, editLines, editCodeLenses);
codeLenses.push(...charDecorationLenses);
logger.debug(`codeLenses: ${JSON.stringify(codeLenses)}`);

workDoneProgress?.done();
if (resultProgress) {
Expand All @@ -251,31 +251,31 @@ export class CodeLensProvider implements Feature {
}

getCharDiffDecoration(originLines: string[], editLines: string[], editCodeLenses: CodeLens[]) {
const editCharCodeLenses: CodeLens[] = []
const changes = diffChars(originLines.join(''), editLines.join(''))
const editCharCodeLenses: CodeLens[] = [];
const changes = diffChars(originLines.join(""), editLines.join(""));
let index = 0;
changes.forEach(item => {
changes.forEach((item) => {
if (item.added) {
const position = this.getPositionFromIndex(index, editCodeLenses)
const position = this.getPositionFromIndex(index, editCodeLenses);
const codeLensRange: Range = {
start: position,
end: { line: position.line, character: position.character + (item.count??0) },
end: { line: position.line, character: position.character + (item.count ?? 0) },
};
const codeLens = {
range: codeLensRange,
data: {
type: codeLensType,
text: 'inserted' as const,
text: "inserted" as const,
},
};
editCharCodeLenses.push(codeLens)
} else if(item.removed) {
editCharCodeLenses.push(codeLens);
} else if (item.removed) {
// nothing
} else {
index += item.count ?? 0
index += item.count ?? 0;
}
})
return editCharCodeLenses
});
return editCharCodeLenses;
}

getPositionFromIndex(index: number, editCodeLenses: CodeLens[]): Position {
Expand All @@ -286,24 +286,24 @@ export class CodeLensProvider implements Feature {
const item = editCodeLenses[i];
const range = item?.range;
if (!range) {
continue
continue;
}
const rangeLength = range.end.character - range.start.character + length
if (index >= length && index <= rangeLength) {
line = range.start.line
character = index - length
const rangeLength = range.end.character - range.start.character + length;
if (index >= length && index <= rangeLength) {
line = range.start.line;
character = index - length;
return {
line,
character
}
} else {
length = rangeLength
}
character,
};
} else {
length = rangeLength;
}
}

return {
line,
character
}
character,
};
}
}
2 changes: 1 addition & 1 deletion clients/tabby-agent/src/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ export type ChangesPreviewLineType =
| "inserted"
| "deleted";

export type ChangesPreviewTextType = "inserted"| "deleted"
export type ChangesPreviewTextType = "inserted" | "deleted";

/**
* Extends LSP method Completion Request(↩️)
Expand Down
4 changes: 2 additions & 2 deletions clients/vscode/src/lsp/CodeLensMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const decorationTypes: Record<string, TextEditorDecorationType> = {

const textDecorationTypes: Record<string, TextEditorDecorationType> = {
inserted: decorationTypeTextInserted,
}
};

export class CodeLensMiddleware implements VscodeLspCodeLensMiddleware {
private readonly decorationMap = new Map<TextEditor, Map<TextEditorDecorationType, Range[]>>();
Expand Down Expand Up @@ -109,7 +109,7 @@ export class CodeLensMiddleware implements VscodeLspCodeLensMiddleware {
this.addDecorationRange(editor, decorationType, decorationRange);
}
}
const textType = codeLens.data.text
const textType = codeLens.data.text;
if (typeof textType === "string" && textType in textDecorationTypes) {
const decorationType = textDecorationTypes[textType];
if (decorationType) {
Expand Down

0 comments on commit 3bd2214

Please sign in to comment.