Skip to content

Commit 2a6b0f6

Browse files
lambdalisueclaude
andcommitted
fix: resolve all type checking and linting issues
- Fix type errors in refiners by properly handling async iterables - Fix type errors in grep/vimgrep sources by using type assertions - Remove unused imports and variables - Fix async function without await in smart_grep renderer - Ensure all code passes type checking and linting 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 02f236f commit 2a6b0f6

File tree

5 files changed

+30
-17
lines changed

5 files changed

+30
-17
lines changed

builtin/refiner/buffer_info.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as fn from "@denops/std/function";
2+
import type { IdItem } from "@vim-fall/core/item";
23
import { defineRefiner, type Refiner } from "../../refiner.ts";
34

45
type Detail = {
@@ -84,7 +85,13 @@ export function bufferInfo(
8485
const minLines = options.minLines;
8586
const maxLines = options.maxLines;
8687

87-
return defineRefiner(async (denops, { items }) => {
88+
return defineRefiner(async function* (denops, { items }) {
89+
// Convert async iterable to array first
90+
const itemsArray: IdItem<Detail>[] = [];
91+
for await (const item of items) {
92+
itemsArray.push(item);
93+
}
94+
8895
// Get all buffer info at once for efficiency
8996
const allBufinfo = await fn.getbufinfo(denops);
9097
const bufInfoMap = new Map(
@@ -93,7 +100,7 @@ export function bufferInfo(
93100

94101
// Process items and filter
95102
const results = await Promise.all(
96-
items.map(async (item) => {
103+
itemsArray.map(async (item) => {
97104
const { bufnr } = item.detail;
98105
const bufinfo = bufInfoMap.get(bufnr);
99106

@@ -102,17 +109,17 @@ export function bufferInfo(
102109
}
103110

104111
// Check modification status
105-
if (modified !== undefined && bufinfo.changed !== (modified ? 1 : 0)) {
112+
if (modified !== undefined && !!bufinfo.changed !== modified) {
106113
return null;
107114
}
108115

109116
// Check listed status
110-
if (listed !== undefined && bufinfo.listed !== (listed ? 1 : 0)) {
117+
if (listed !== undefined && !!bufinfo.listed !== listed) {
111118
return null;
112119
}
113120

114121
// Check loaded status
115-
if (loaded !== undefined && bufinfo.loaded !== (loaded ? 1 : 0)) {
122+
if (loaded !== undefined && !!bufinfo.loaded !== loaded) {
116123
return null;
117124
}
118125

@@ -180,6 +187,7 @@ export function bufferInfo(
180187
);
181188

182189
// Return only non-null items
183-
return results.filter((item) => item !== null);
190+
const filtered = results.filter((item): item is IdItem<Detail> => item !== null);
191+
yield* filtered;
184192
});
185193
}

builtin/refiner/file_info.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { IdItem } from "@vim-fall/core/item";
12
import { defineRefiner, type Refiner } from "../../refiner.ts";
23
import { extname } from "@std/path/extname";
34

@@ -85,15 +86,21 @@ export function fileInfo(
8586
const excludeHidden = options.excludeHidden ?? false;
8687
const excludePatterns = options.excludePatterns ?? [];
8788

88-
return defineRefiner(async (_denops, { items }) => {
89+
return defineRefiner(async function* (_denops, { items }) {
90+
// Convert async iterable to array first
91+
const itemsArray: IdItem<Detail>[] = [];
92+
for await (const item of items) {
93+
itemsArray.push(item);
94+
}
95+
8996
// Process items in parallel and filter
9097
const results = await Promise.all(
91-
items.map(async (item) => {
98+
itemsArray.map(async (item) => {
9299
const { path } = item.detail;
93100

94101
// Check if hidden file should be excluded
95102
if (
96-
excludeHidden && path.split("/").some((part) => part.startsWith("."))
103+
excludeHidden && path.split("/").some((part: string) => part.startsWith("."))
97104
) {
98105
return null;
99106
}
@@ -173,6 +180,7 @@ export function fileInfo(
173180
);
174181

175182
// Return only non-null items
176-
return results.filter((item) => item !== null);
183+
const filtered = results.filter((item): item is IdItem<Detail> => item !== null);
184+
yield* filtered;
177185
});
178186
}

builtin/renderer/smart_grep.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { defineRenderer, type Renderer } from "../../renderer.ts";
22
import { dirname } from "@std/path/dirname";
3-
import { basename } from "@std/path/basename";
43

54
type Detail = {
65
/**
@@ -82,7 +81,7 @@ export function smartGrep(
8281
const colorize = options.colorize ?? false;
8382
const alignColumns = options.alignColumns ?? true;
8483

85-
return defineRenderer(async (_denops, { items }) => {
84+
return defineRenderer((_denops, { items }) => {
8685
if (items.length === 0) {
8786
return;
8887
}
@@ -150,7 +149,6 @@ export function smartGrep(
150149

151150
// Format path
152151
const displayPath = useRelativePaths ? path : path;
153-
const filename = basename(displayPath);
154152
const pathPart = alignColumns
155153
? displayPath.padEnd(maxPathWidth)
156154
: displayPath;

builtin/source/grep.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export function grep(
100100
signal?.throwIfAborted();
101101

102102
// Get results from quickfix list
103-
const qflist = await fn.getqflist(denops) as Array<{
103+
const qflist = await fn.getqflist(denops) as unknown as Array<{
104104
bufnr: number;
105105
lnum: number;
106106
col: number;
@@ -146,7 +146,6 @@ export function grep(
146146
} else {
147147
// Execute grep directly and parse output
148148
const grepprg = await denops.eval("&grepprg") as string;
149-
const grepformat = await denops.eval("&grepformat") as string;
150149

151150
// This is a simplified implementation
152151
// In practice, we'd need to properly parse grepformat

builtin/source/vimgrep.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export function vimgrep(
106106
signal?.throwIfAborted();
107107

108108
// Get results from quickfix list
109-
const qflist = await fn.getqflist(denops) as Array<{
109+
const qflist = await fn.getqflist(denops) as unknown as Array<{
110110
bufnr: number;
111111
lnum: number;
112112
col: number;
@@ -157,7 +157,7 @@ export function vimgrep(
157157
await denops.cmd(`silent! ${vimgrepCmd}`);
158158
signal?.throwIfAborted();
159159

160-
const qflist = await fn.getqflist(denops) as Array<{
160+
const qflist = await fn.getqflist(denops) as unknown as Array<{
161161
bufnr: number;
162162
lnum: number;
163163
col: number;

0 commit comments

Comments
 (0)