From 9d25fab5cb4daf16ac49e23dde671e730172883a Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Sun, 17 Nov 2024 21:40:46 -0800 Subject: [PATCH] fix linting --- .../contrib/void/browser/findDiffs.ts | 16 ++--- .../contrib/void/browser/registerActions.ts | 2 +- .../void/browser/registerInlineDiffs.ts | 64 +++++++++---------- .../contrib/void/browser/registerThreads.ts | 2 +- 4 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/vs/workbench/contrib/void/browser/findDiffs.ts b/src/vs/workbench/contrib/void/browser/findDiffs.ts index 32e77338..cfaed6a6 100644 --- a/src/vs/workbench/contrib/void/browser/findDiffs.ts +++ b/src/vs/workbench/contrib/void/browser/findDiffs.ts @@ -23,9 +23,9 @@ export type SuggestedEdit = { // start/end of original file originalRange: Range; - type: 'insertion' | 'deletion' | 'edit', - originalContent: string, // original content (originalfile[originalStart...originalEnd]) - newContent: string, + type: 'insertion' | 'deletion' | 'edit'; + originalContent: string; // original content (originalfile[originalStart...originalEnd]) + newContent: string; } export function findDiffs(oldStr: string, newStr: string) { @@ -44,11 +44,11 @@ export function findDiffs(oldStr: string, newStr: string) { let streakStartInNewFile: number | undefined = undefined let streakStartInOldFile: number | undefined = undefined - let oldStrLines = ('\n' + oldStr).split('\n') // add newline so indexing starts at 1 + const oldStrLines = ('\n' + oldStr).split('\n') // add newline so indexing starts at 1 // let newStrLines = ('\n' + newStr).split('\n') const replacements: BaseDiff[] = [] - for (let line of lineByLineChanges) { + for (const line of lineByLineChanges) { // no change on this line if (!line.added && !line.removed) { @@ -59,18 +59,18 @@ export function findDiffs(oldStr: string, newStr: string) { if (streakStartInNewFile !== undefined) { let type: 'edit' | 'insertion' | 'deletion' = 'edit' - let startLine = streakStartInNewFile + const startLine = streakStartInNewFile let endLine = newFileLineNum - 1 // don't include current line, the edit was up to this line but not including it let startCol = 1 let endCol = Number.MAX_SAFE_INTEGER - let originalStartLine = streakStartInOldFile! + const originalStartLine = streakStartInOldFile! let originalEndLine = oldFileLineNum - 1 // don't include current line, the edit was up to this line but not including it // let originalStartCol = 0 // let originalEndCol = Number.MAX_SAFE_INTEGER // let newContent = newStrLines.slice(startLine, endLine + 1).join('\n') - let originalContent = oldStrLines.slice(originalStartLine, originalEndLine + 1).join('\n') + const originalContent = oldStrLines.slice(originalStartLine, originalEndLine + 1).join('\n') // if the range is empty, mark it as a deletion / insertion (both won't be true at once) // DELETION diff --git a/src/vs/workbench/contrib/void/browser/registerActions.ts b/src/vs/workbench/contrib/void/browser/registerActions.ts index 9a1ebb35..c29415bf 100644 --- a/src/vs/workbench/contrib/void/browser/registerActions.ts +++ b/src/vs/workbench/contrib/void/browser/registerActions.ts @@ -25,7 +25,7 @@ const roundRangeToLines = (range: IRange | null | undefined) => { if (!range) return null // IRange is 1-indexed - let endLine = range.endColumn === 1 ? range.endLineNumber - 1 : range.endLineNumber // e.g. if the user triple clicks, it selects column=0, line=line -> column=0, line=line+1 + const endLine = range.endColumn === 1 ? range.endLineNumber - 1 : range.endLineNumber // e.g. if the user triple clicks, it selects column=0, line=line -> column=0, line=line+1 const newRange: IRange = { startLineNumber: range.startLineNumber, startColumn: 1, diff --git a/src/vs/workbench/contrib/void/browser/registerInlineDiffs.ts b/src/vs/workbench/contrib/void/browser/registerInlineDiffs.ts index d3412461..9bb699eb 100644 --- a/src/vs/workbench/contrib/void/browser/registerInlineDiffs.ts +++ b/src/vs/workbench/contrib/void/browser/registerInlineDiffs.ts @@ -58,8 +58,8 @@ const readModel = (model: ITextModel) => { export type Diff = { - diffid: number, - diffareaid: number, // the diff area this diff belongs to, "computed" + diffid: number; + diffareaid: number; // the diff area this diff belongs to, "computed" type: 'edit' | 'insertion' | 'deletion'; originalCode: string; @@ -81,25 +81,25 @@ export type Diff = { // _ means anything we don't include if we clone it type DiffArea = { - diffareaid: number, - // originalStartLine: number, - // originalEndLine: number, - originalCode: string, - startLine: number, - endLine: number, + diffareaid: number; + // originalStartLine: number; + // originalEndLine: number; + originalCode: string; + startLine: number; + endLine: number; - _model: ITextModel, // the model (if we clone it, the function keeps track of the model id) - _diffOfId: Record, // diff of id in this DiffArea - _disposeSweepStyles: (() => void) | null, - // _generationid: number, + _model: ITextModel; // the model (if we clone it; the function keeps track of the model id) + _diffOfId: Record; // diff of id in this DiffArea + _disposeSweepStyles: (() => void) | null; + // _generationid: number; } & ({ _sweepState: { - isStreaming: true, + isStreaming: true; line: number; } | { - isStreaming: false, + isStreaming: false; line: null; - } + }; }) const diffAreaSnapshotKeys = [ @@ -114,14 +114,14 @@ type DiffAreaSnapshot = Pick type HistorySnapshot = { - snapshottedDiffAreaOfId: Record, - code: string, + snapshottedDiffAreaOfId: Record; + code: string; } & ({ - type: 'ctrl+k', - ctrlKText: string + type: 'ctrl+k'; + ctrlKText: string; } | { - type: 'ctrl+l', + type: 'ctrl+l'; }) @@ -185,16 +185,16 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { // it's as if we just called _write, now all we need to do is realign and refresh - let refreshIds: Set = new Set() + const refreshIds: Set = new Set() // realign - for (let change of e.changes) { + for (const change of e.changes) { const ids = this._realignAllDiffAreasLines(model, change.text, change.range) ids.forEach(id => refreshIds.add(id)) } // refresh const content = readModel(model) if (content === null) return - for (let diffareaid of refreshIds) { + for (const diffareaid of refreshIds) { const diffArea = this.diffAreaOfId[diffareaid] const computedDiffs = findDiffs(diffArea.originalCode, content) this._refreshDiffArea(diffArea, computedDiffs) @@ -366,7 +366,7 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { const diffAreaOfId = this.diffAreaOfId const snapshottedDiffAreaOfId: Record = {} - for (let diffareaid in diffAreaOfId) { + for (const diffareaid in diffAreaOfId) { const diffArea = diffAreaOfId[diffareaid] snapshottedDiffAreaOfId[diffareaid] = structuredClone( // a structured clone must be on a JSON object Object.fromEntries(diffAreaSnapshotKeys.map(key => [key, diffArea[key]])) @@ -384,7 +384,7 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { const { snapshottedDiffAreaOfId, code } = structuredClone(snapshot) // don't want to destroy the snapshot // delete all current decorations (diffs, sweep styles) so we don't have any unwanted leftover decorations - for (let diffareaid in this.diffAreaOfId) { + for (const diffareaid in this.diffAreaOfId) { const diffArea = this.diffAreaOfId[diffareaid] this._deleteDiffs(diffArea) this._deleteSweepStyles(diffArea) @@ -393,7 +393,7 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { // restore diffAreaOfId and diffAreasOfModelId this.diffAreaOfId = {} this.diffAreasOfModelId[model.id].clear() - for (let diffareaid in snapshottedDiffAreaOfId) { + for (const diffareaid in snapshottedDiffAreaOfId) { this.diffAreaOfId[diffareaid] = { ...snapshottedDiffAreaOfId[diffareaid], _diffOfId: {}, @@ -411,7 +411,7 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { const newCode = code this._writeText(model, code, { startColumn: 1, startLineNumber: 1, endLineNumber: model.getLineCount(), endColumn: Number.MAX_SAFE_INTEGER }) if (newCode === null) return - for (let diffareaid in this.diffAreaOfId) { + for (const diffareaid in this.diffAreaOfId) { const diffArea = this.diffAreaOfId[diffareaid] const computedDiffs = findDiffs(diffArea.originalCode, newCode) this._refreshDiffArea(diffArea, computedDiffs) @@ -476,9 +476,9 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { // changes the start/line locations of all DiffAreas on the page (adjust their start/end based on the change) based on the change that was recently made - private _realignAllDiffAreasLines(model: ITextModel, text: string, recentChange: { startLineNumber: number; endLineNumber: number; }) { + private _realignAllDiffAreasLines(model: ITextModel, text: string, recentChange: { startLineNumber: number; endLineNumber: number }) { - let diffAreaIdsThatNeedRefreshing: number[] = [] + const diffAreaIdsThatNeedRefreshing: number[] = [] // compute net number of newlines lines that were added/removed const startLine = recentChange.startLineNumber @@ -564,7 +564,7 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { // ----------- 3. Recompute all Diffs in the diffArea ----------- // recompute - for (let computedDiff of computedDiffs) { + for (const computedDiff of computedDiffs) { const diffid = this._diffidPool++ // add the view zone @@ -640,7 +640,7 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { const newFileTop = newCodeSoFar.split('\n').slice(0, (newFileEndLine - 1)).join('\n') const oldFileBottom = diffArea.originalCode.split('\n').slice((oldFileStartLine - 1), Infinity).join('\n') - let newCode = `${newFileTop}\n${oldFileBottom}` + const newCode = `${newFileTop}\n${oldFileBottom}` this._writeText(model, newCode, { startLineNumber: diffArea.startLine, startColumn: 1, endLineNumber: diffArea.endLine, endColumn: Number.MAX_SAFE_INTEGER, } // 1-indexed @@ -662,7 +662,7 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { const endLine = model.getLineCount() // check if there's overlap with any other diffAreas and return early if there is - for (let diffareaid of this.diffAreasOfModelId[model.id]) { + for (const diffareaid of this.diffAreasOfModelId[model.id]) { const da2 = this.diffAreaOfId[diffareaid] if (!da2) continue const noOverlap = da2.startLine > endLine || da2.endLine < beginLine diff --git a/src/vs/workbench/contrib/void/browser/registerThreads.ts b/src/vs/workbench/contrib/void/browser/registerThreads.ts index 5695aded..dc7f3150 100644 --- a/src/vs/workbench/contrib/void/browser/registerThreads.ts +++ b/src/vs/workbench/contrib/void/browser/registerThreads.ts @@ -9,7 +9,7 @@ import { Emitter, Event } from '../../../../base/common/event.js'; // if selectionStr is null, it means just send the whole file export type CodeSelection = { selectionStr: string | null; - fileURI: URI, + fileURI: URI; content: string; }