File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -23,3 +23,16 @@ export async function dispose(resource: unknown): Promise<void> {
2323 await resource [ Symbol . asyncDispose ] ( ) ;
2424 }
2525}
26+
27+ /**
28+ * Ensure the resource is async disposable.
29+ */
30+ export function ensureAsyncDisposable < T > ( resource : T ) : T & AsyncDisposable {
31+ if ( isAsyncDisposable ( resource ) ) {
32+ return resource as T & AsyncDisposable ;
33+ }
34+ return {
35+ ...resource ,
36+ [ Symbol . asyncDispose ] : ( ) => Promise . resolve ( ) ,
37+ } ;
38+ }
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import type {
1616 ItemPickerParams ,
1717} from "jsr:@vim-fall/std@^0.2.0/config" ;
1818
19+ import { ensureAsyncDisposable } from "../lib/dispose.ts" ;
1920import {
2021 getActionPickerParams ,
2122 getGlobalConfig ,
@@ -183,6 +184,7 @@ async function startPicker(
183184 if ( ! action ) {
184185 throw new Error ( `Action "${ actionName } " is not found` ) ;
185186 }
187+ await using _guardAction = ensureAsyncDisposable ( action ) ;
186188 const actionParams = {
187189 // for 'submatch' action
188190 _submatchContext : {
You can’t perform that action at this time.
0 commit comments