@ramarivera/pi-television 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -47,11 +47,14 @@ Supported fields:
47
47
  ```json
48
48
  {
49
49
  "mode": "native-live",
50
+ "includeFolders": true,
50
51
  "maxResults": 20,
51
52
  "refreshMs": 10000
52
53
  }
53
54
  ```
54
55
 
56
+ `includeFolders` defaults to `true`, so folder paths are returned alongside files. Set it to `false` to restrict the picker to regular files only.
57
+
55
58
  ## Local Development
56
59
 
57
60
  This checkout is live-enabled for Pi through:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ramarivera/pi-television",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Pi extension that powers native Pi @file picking with background television-style search",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/extension.ts CHANGED
@@ -33,12 +33,14 @@ export type TelevisionConfig = {
33
33
  mode?: TelevisionMode;
34
34
  maxResults?: number;
35
35
  refreshMs?: number;
36
+ includeFolders?: boolean;
36
37
  };
37
38
 
38
39
  export type TelevisionResolvedConfig = {
39
40
  mode: TelevisionMode;
40
41
  maxResults: number;
41
42
  refreshMs: number;
43
+ includeFolders: boolean;
42
44
  };
43
45
 
44
46
  export type TelevisionSearchResult = {
@@ -53,6 +55,7 @@ export type TelevisionSearchOptions = {
53
55
  signal?: AbortSignal;
54
56
  maxResults?: number;
55
57
  refreshMs?: number;
58
+ includeFolders?: boolean;
56
59
  };
57
60
 
58
61
  export type TelevisionSearcher = (
@@ -82,10 +85,13 @@ export const extensionInfo: ExtensionInfo = {
82
85
  "Pi extension that powers native @file picking with background television-style search",
83
86
  };
84
87
 
88
+ const DEFAULT_INCLUDE_FOLDERS = true;
89
+
85
90
  const defaultResolvedConfig: TelevisionResolvedConfig = {
86
91
  mode: "native-live",
87
92
  maxResults: DEFAULT_MAX_RESULTS,
88
93
  refreshMs: DEFAULT_REFRESH_MS,
94
+ includeFolders: DEFAULT_INCLUDE_FOLDERS,
89
95
  };
90
96
 
91
97
  type FileIndexCache = {
@@ -134,6 +140,8 @@ function normalizeTelevisionConfig(
134
140
  mode: config?.mode ?? defaultResolvedConfig.mode,
135
141
  maxResults: config?.maxResults ?? defaultResolvedConfig.maxResults,
136
142
  refreshMs: config?.refreshMs ?? defaultResolvedConfig.refreshMs,
143
+ includeFolders:
144
+ config?.includeFolders ?? defaultResolvedConfig.includeFolders,
137
145
  };
138
146
  }
139
147
 
@@ -212,6 +220,7 @@ export function createDefaultSearcher(pi: ExtensionAPI): TelevisionSearcher {
212
220
  signal,
213
221
  maxResults = DEFAULT_MAX_RESULTS,
214
222
  refreshMs = DEFAULT_REFRESH_MS,
223
+ includeFolders = DEFAULT_INCLUDE_FOLDERS,
215
224
  }) => {
216
225
  const now = Date.now();
217
226
  const cached = cache.get(cwd);
@@ -225,10 +234,9 @@ export function createDefaultSearcher(pi: ExtensionAPI): TelevisionSearcher {
225
234
  return rankTelevisionResults(entries, query, maxResults);
226
235
  }
227
236
 
228
- const pending = (async () => {
229
- const result = await pi.exec(
230
- "fd",
231
- [
237
+ const fdArgs = includeFolders
238
+ ? ["--hidden", "--follow", "--exclude", ".git", "--strip-cwd-prefix"]
239
+ : [
232
240
  "--type",
233
241
  "f",
234
242
  "--hidden",
@@ -236,13 +244,14 @@ export function createDefaultSearcher(pi: ExtensionAPI): TelevisionSearcher {
236
244
  "--exclude",
237
245
  ".git",
238
246
  "--strip-cwd-prefix",
239
- ],
240
- {
241
- cwd,
242
- signal,
243
- timeout: 10_000,
244
- },
245
- );
247
+ ];
248
+
249
+ const pending = (async () => {
250
+ const result = await pi.exec("fd", fdArgs, {
251
+ cwd,
252
+ signal,
253
+ timeout: 10_000,
254
+ });
246
255
 
247
256
  if (result.code !== 0) {
248
257
  const details = result.stderr.trim() || `exit code ${result.code}`;
@@ -288,6 +297,7 @@ export function createTelevisionAutocompleteProvider(
288
297
  signal: options.signal,
289
298
  maxResults: config.maxResults,
290
299
  refreshMs: config.refreshMs,
300
+ includeFolders: config.includeFolders,
291
301
  });
292
302
 
293
303
  if (options.signal.aborted || results.length === 0) {
@@ -363,6 +373,7 @@ async function findFiles(
363
373
  signal: ctx.signal,
364
374
  maxResults: config.maxResults,
365
375
  refreshMs: config.refreshMs,
376
+ includeFolders: config.includeFolders,
366
377
  });
367
378
  } finally {
368
379
  ctx.ui.setStatus(STATUS_KEY, undefined);