From 3bd2214c15638975dc97ef85c3e14eb0b592481d Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 16 Jan 2025 05:44:46 +0000 Subject: [PATCH] [autofix.ci] apply automated fixes --- clients/tabby-agent/src/codeLens.ts | 78 ++++++++++---------- clients/tabby-agent/src/protocol.ts | 2 +- clients/vscode/src/lsp/CodeLensMiddleware.ts | 4 +- 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/clients/tabby-agent/src/codeLens.ts b/clients/tabby-agent/src/codeLens.ts index 0008bf5ca2b8..56301e758e98 100644 --- a/clients/tabby-agent/src/codeLens.ts +++ b/clients/tabby-agent/src/codeLens.ts @@ -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) {} @@ -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; @@ -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 = { @@ -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 = { @@ -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 = { @@ -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 = { @@ -220,7 +220,7 @@ export class CodeLensProvider implements Feature { line: changesPreviewLineType.deleted, }, }; - originLines.unshift(text) + originLines.unshift(text); break; default: break; @@ -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) { @@ -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 { @@ -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, + }; } } diff --git a/clients/tabby-agent/src/protocol.ts b/clients/tabby-agent/src/protocol.ts index 8f9477d7e2f9..8c2207359e11 100644 --- a/clients/tabby-agent/src/protocol.ts +++ b/clients/tabby-agent/src/protocol.ts @@ -291,7 +291,7 @@ export type ChangesPreviewLineType = | "inserted" | "deleted"; -export type ChangesPreviewTextType = "inserted"| "deleted" +export type ChangesPreviewTextType = "inserted" | "deleted"; /** * Extends LSP method Completion Request(↩️) diff --git a/clients/vscode/src/lsp/CodeLensMiddleware.ts b/clients/vscode/src/lsp/CodeLensMiddleware.ts index 520f4c42a366..71829481390c 100644 --- a/clients/vscode/src/lsp/CodeLensMiddleware.ts +++ b/clients/vscode/src/lsp/CodeLensMiddleware.ts @@ -68,7 +68,7 @@ const decorationTypes: Record = { const textDecorationTypes: Record = { inserted: decorationTypeTextInserted, -} +}; export class CodeLensMiddleware implements VscodeLspCodeLensMiddleware { private readonly decorationMap = new Map>(); @@ -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) {