Skip to content

Commit

Permalink
fix: Fix some typos (#589)
Browse files Browse the repository at this point in the history
  • Loading branch information
ic-768 authored Jul 1, 2024
1 parent 9816094 commit 6ae1269
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 56 deletions.
6 changes: 3 additions & 3 deletions src/floating/floatingPreview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 3 additions & 5 deletions src/highlight/filename.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions src/lists/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Task extends EventEmitter implements ListTask {
});
});
rl.on('close', () => {
remain = remain - 1;
remain -= 1;
if (remain === 0) {
this.emit('end');
}
Expand Down Expand Up @@ -119,8 +119,8 @@ export const fileList = registerList<Arg, any>({
},
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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/lists/presets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
Expand Down
6 changes: 3 additions & 3 deletions src/locator/markSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ export class MarkSource<TreeNode extends BaseTreeNode<TreeNode>> {
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;
});
}
}
80 changes: 40 additions & 40 deletions src/painter/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,35 +103,35 @@ 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];
const widthLimit = widthLimits[i];
if (!volume || !widthLimit) continue;
const width = Math.ceil(volume * unit);
if (width > widthLimit) {
widthes[i] = widthLimit;
widths[i] = widthLimit;
totalWidth -= widthLimit;
volumes[i] = 0;
}
}
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(
Expand Down Expand Up @@ -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,
Expand All @@ -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,
];
Expand All @@ -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',
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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({
Expand All @@ -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)[] = [];
Expand Down

0 comments on commit 6ae1269

Please sign in to comment.