File tree 1 file changed +14
-0
lines changed
1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -536,6 +536,20 @@ function M.get(id, include_hidden)
536
536
return (term and (include_hidden == true or not term .hidden )) and term or nil
537
537
end
538
538
539
+ --- Get the first terminal that matches a predicate
540
+ --- @param predicate fun ( term : Terminal ): boolean
541
+ --- @return Terminal ?
542
+ function M .find (predicate )
543
+ if type (predicate ) ~= " function" then
544
+ utils .notify (" terminal.find expects a function, got " .. type (predicate ), " error" )
545
+ return
546
+ end
547
+ for _ , term in pairs (terminals ) do
548
+ if predicate (term ) then return term end
549
+ end
550
+ return nil
551
+ end
552
+
539
553
--- Return the potentially non contiguous map of terminals as a sorted array
540
554
--- @param include_hidden boolean ? whether or nor to filter out hidden
541
555
--- @return Terminal[]
You can’t perform that action at this time.
0 commit comments