From 7e38da929499a7065c5a8e77b346f568c88283f6 Mon Sep 17 00:00:00 2001 From: Josh Mu Date: Sat, 1 Apr 2023 17:37:30 +1000 Subject: [PATCH] feat: option to apply custom rg commands --- src/periscope.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/periscope.ts b/src/periscope.ts index 1234ca2..93a63ac 100644 --- a/src/periscope.ts +++ b/src/periscope.ts @@ -88,7 +88,7 @@ export const periscope = () => { function setupRgMenuActions() { reset(); - qp.placeholder = '🫧 Rg Menu Actions (Space key to check/uncheck, Enter key to continue)'; + qp.placeholder = '🫧 Select actions or type custom rg options (Space key to check/uncheck)'; qp.canSelectMany = true; // add items from the config @@ -104,6 +104,13 @@ export const periscope = () => { function next() { rgMenuActionsSelected = (qp.selectedItems as QPItemRgMenuAction[]).map(item => item.data.rgOption); + + // if no actions selected, then use the current query as a custom command to rg + if (!rgMenuActionsSelected.length && qp.value) { + rgMenuActionsSelected.push(qp.value); + qp.value = ''; + } + setupQuickPickForQuery(); } @@ -119,7 +126,6 @@ export const periscope = () => { qp.items = []; qp.canSelectMany = false; qp.value = getSelectedText(); - console.log('here'); disposables.query.push( qp.onDidChangeValue(onDidChangeValue), qp.onDidChangeActive(onDidChangeActive),