diff --git a/src/floating/floatingPreview.ts b/src/floating/floatingPreview.ts index bdf1870..ec34f29 100644 --- a/src/floating/floatingPreview.ts +++ b/src/floating/floatingPreview.ts @@ -372,16 +372,16 @@ export class FloatingPreview implements Disposable { return; } - const reigsteredActions = + const registeredActions = this.registeredPreviewActions.get(previewStrategy); - if (!reigsteredActions) { + if (!registeredActions) { await window.showInformationMessage( `coc-explorer no support preview strategy(${previewStrategy})`, ); return; } - const openArgs = await reigsteredActions({ + const openArgs = await registeredActions({ source, node, nodeIndex, diff --git a/src/highlight/filename.ts b/src/highlight/filename.ts index 9a89698..f0ad7dd 100644 --- a/src/highlight/filename.ts +++ b/src/highlight/filename.ts @@ -36,11 +36,9 @@ export class FilenameHighlight { } getGitHighlight(status: GitMixedStatus) { - if (status.x === GitFormat.ignored) { - return gitHighlights.ignored; - } - - return getGitFormatHighlight(status.y); + return status.x === GitFormat.ignored + ? gitHighlights.ignored + : getGitFormatHighlight(status.y); } getHighlight( diff --git a/src/lists/files.ts b/src/lists/files.ts index baff16e..9b05c99 100644 --- a/src/lists/files.ts +++ b/src/lists/files.ts @@ -45,7 +45,7 @@ class Task extends EventEmitter implements ListTask { }); }); rl.on('close', () => { - remain = remain - 1; + remain -= 1; if (remain === 0) { this.emit('end'); } @@ -119,8 +119,8 @@ export const fileList = registerList({ }, init() { this.addLocationActions(); - this.addAction('reveal', async ({ arg, item }) => { - const loc = await this.convertLocation(item.location!); + this.addAction('reveal', async ({ arg, item: { location } }) => { + const loc = await this.convertLocation(location!); if (arg.revealCallback) { await arg.revealCallback(loc); } diff --git a/src/lists/presets.ts b/src/lists/presets.ts index 754a3c0..bb76133 100644 --- a/src/lists/presets.ts +++ b/src/lists/presets.ts @@ -11,9 +11,9 @@ export class PresetList extends BasicList { constructor(nvim: Neovim) { super(nvim); - this.addAction('do', async (item) => { + this.addAction('do', async ({ data }) => { this.nvim - .command(`CocCommand explorer --preset ${item.data.name as string}`) + .command(`CocCommand explorer --preset ${data.name as string}`) .catch(logger.error); }); } diff --git a/src/locator/markSource.ts b/src/locator/markSource.ts index f6a0d3e..718e81c 100644 --- a/src/locator/markSource.ts +++ b/src/locator/markSource.ts @@ -36,9 +36,9 @@ export class MarkSource> { if (sourceIndex === undefined) { return; } - this.explorer.sources.slice(sourceIndex + 1).forEach((source) => { - source.view.startLineIndex += offset; - source.view.endLineIndex += offset; + this.explorer.sources.slice(sourceIndex + 1).forEach(({ view }) => { + view.startLineIndex += offset; + view.endLineIndex += offset; }); } } diff --git a/src/painter/util.ts b/src/painter/util.ts index 55ca71c..b8054a3 100644 --- a/src/painter/util.ts +++ b/src/painter/util.ts @@ -103,7 +103,7 @@ export function divideVolumeBy( widthLimits?: number[], ) { let unit = totalWidth / sum(volumes); - const widthes: number[] = new Array(volumes.length); + const widths: number[] = new Array(volumes.length); if (widthLimits) { for (let i = 0; i < volumes.length; i++) { const volume = volumes[i]; @@ -111,7 +111,7 @@ export function divideVolumeBy( if (!volume || !widthLimit) continue; const width = Math.ceil(volume * unit); if (width > widthLimit) { - widthes[i] = widthLimit; + widths[i] = widthLimit; totalWidth -= widthLimit; volumes[i] = 0; } @@ -119,19 +119,19 @@ export function divideVolumeBy( unit = totalWidth / sum(volumes); } for (let i = 0; i < volumes.length; i++) { - if (widthes[i] === undefined) { + if (widths[i] === undefined) { const volume = volumes[i]; if (!volume) continue; const width = Math.ceil(volume * unit); if (width <= totalWidth) { totalWidth -= width; - widthes[i] = width; + widths[i] = width; } else { - widthes[i] = totalWidth; + widths[i] = totalWidth; } } } - return widthes; + return widths; } export async function handlePadding( @@ -211,7 +211,7 @@ export async function handleGrow( drawableList: DrawableWithWidth[], ): Promise<(DrawContentWithWidth | DrawUnknown)[]> { const allSpaceWidth = fullwidth - usedWidth; - const spaceWids = divideVolumeBy( + const spaceWidths = divideVolumeBy( allSpaceWidth, drawableList.map((c) => c.type === 'group' && c.flexible?.grow ? c.flexible.growVolume ?? 1 : 0, @@ -234,16 +234,16 @@ export async function handleGrow( return item.contents; } - const spaceWid = spaceWids[idx]; - if (!spaceWid) return; + const spaceWidth = spaceWidths[idx]; + if (!spaceWidth) return; switch (item.flexible.grow) { case 'left': return [ { type: 'content', - content: ' '.repeat(spaceWid), - width: spaceWid, + content: ' '.repeat(spaceWidth), + width: spaceWidth, }, ...item.contents, ]; @@ -252,13 +252,13 @@ export async function handleGrow( ...item.contents, { type: 'content', - content: ' '.repeat(spaceWid), - width: spaceWid, + content: ' '.repeat(spaceWidth), + width: spaceWidth, }, ]; case 'center': { - const leftSpace = Math.floor(spaceWid / 2); - const rightSpace = spaceWid - leftSpace; + const leftSpace = Math.floor(spaceWidth / 2); + const rightSpace = spaceWidth - leftSpace; return [ { type: 'content', @@ -294,7 +294,7 @@ export async function handleOmit( drawableList: DrawableWithWidth[], ): Promise<(DrawContentWithWidth | DrawUnknown)[]> { const allOmitWidth = usedWidth - fullwidth; - const omitWids = divideVolumeBy( + const omitWidths = divideVolumeBy( allOmitWidth, drawableList.map((c) => c.type === 'group' && c.flexible?.omit ? c.flexible.omitVolume ?? 1 : 0, @@ -329,61 +329,61 @@ export async function handleOmit( return item.contents; } - const omitWid = omitWids[idx]; - if (!omitWid) return; + const omitWidth = omitWidths[idx]; + if (!omitWidth) return; const contents: (DrawContentWithWidth | DrawUnknown)[] = []; switch (item.flexible.omit) { case 'left': { - const cutWid = omitWid + 1; - let remainCutWid = cutWid; + const cutWidth = omitWidth + 1; + let remainCutWidth = cutWidth; for (const c of item.contents) { if (c.type !== 'content') { contents.push(c); continue; } - if (remainCutWid < 0) { + if (remainCutWidth < 0) { contents.push(c); - } else if (remainCutWid < c.width) { + } else if (remainCutWidth < c.width) { contents.push({ type: 'content', content: '‥', width: 1, group: omitSymbolHighlight.group, }); - if (remainCutWid > 0) { + if (remainCutWidth > 0) { contents.push({ ...c, - content: await displaySlice(c.content, remainCutWid), - width: c.width - remainCutWid, + content: await displaySlice(c.content, remainCutWidth), + width: c.width - remainCutWidth, }); } } - remainCutWid -= c.width; + remainCutWidth -= c.width; } return contents; } case 'right': { - const cutWid = omitWid + 1; - const contentWid = sum( + const cutWidth = omitWidth + 1; + const contentWidth = sum( item.contents.map((c) => (c.type === 'content' ? c.width : 0)), ); - let remainWid = contentWid - cutWid; + let remainWidth = contentWidth - cutWidth; for (const c of item.contents) { if (c.type !== 'content') { contents.push(c); continue; } - if (remainWid >= c.width) { + if (remainWidth >= c.width) { contents.push(c); - } else if (remainWid < c.width) { - if (remainWid > 0) { + } else if (remainWidth < c.width) { + if (remainWidth > 0) { contents.push({ ...c, - content: await displaySlice(c.content, 0, remainWid), - width: remainWid, + content: await displaySlice(c.content, 0, remainWidth), + width: remainWidth, }); } contents.push({ @@ -394,18 +394,18 @@ export async function handleOmit( }); break; } - remainWid -= c.width; + remainWidth -= c.width; } return contents; } case 'center': { - const contentWid = sum( + const contentWidth = sum( item.contents.map((c) => (c.type === 'content' ? c.width : 0)), ); - const cutWid = omitWid + 1; - const remainWid = contentWid - cutWid; - const leftCutPos = Math.floor(remainWid / 2); - const rightCutPos = contentWid - (remainWid - leftCutPos); + const cutWidth = omitWidth + 1; + const remainWidth = contentWidth - cutWidth; + const leftCutPos = Math.floor(remainWidth / 2); + const rightCutPos = contentWidth - (remainWidth - leftCutPos); let itemStartPos = 0; let itemEndPos = 0; const contents: (DrawContentWithWidth | DrawUnknown)[] = [];