File tree 1 file changed +17
-0
lines changed
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -536,6 +536,23 @@ 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
+ vim .notify_once (
545
+ " [toggleterm.nvim] terminal.find predicate expects a function, got " .. type (predicate ),
546
+ vim .log .levels .ERROR
547
+ )
548
+ return
549
+ end
550
+ for _ , term in pairs (terminals ) do
551
+ if predicate (term ) then return term end
552
+ end
553
+ return nil
554
+ end
555
+
539
556
--- Return the potentially non contiguous map of terminals as a sorted array
540
557
--- @param include_hidden boolean ? whether or nor to filter out hidden
541
558
--- @return Terminal[]
You can’t perform that action at this time.
0 commit comments