Commit 94c34315 authored by Ivan Mazhukin's avatar Ivan Mazhukin

add clickable app confirmation choices

parent b79e9216
...@@ -43,7 +43,7 @@ The same VSIX can be installed from the VS Code command `Extensions: Install fro ...@@ -43,7 +43,7 @@ The same VSIX can be installed from the VS Code command `Extensions: Install fro
- `Rerun last command`: repeats the last generated command. - `Rerun last command`: repeats the last generated command.
- `Open log folder`: opens `${XDG_STATE_HOME:-$HOME/.local/state}/epm-docker-test` or the configured log root. - `Open log folder`: opens `${XDG_STATE_HOME:-$HOME/.local/state}/epm-docker-test` or the configured log root.
When an app name is requested, it is inferred from the active editor if the file is in `play.d`, `pack.d`, or `repack.d`. The extension first checks simple shell variables such as `PRODUCT=rstudio` or `PKGNAME=rstudio`, then falls back to the file name without extension. The inferred app is prefilled in the app input field and can be edited before running. When an app name is requested, it is inferred from the active editor if the file is in `play.d`, `pack.d`, or `repack.d`. The extension first checks simple shell variables such as `PRODUCT=rstudio` or `PKGNAME=rstudio`, then falls back to the file name without extension. If an app is inferred, the extension shows clickable `OK`, `Edit`, and `Cancel` choices; `Edit` opens the app input field.
## Favorites ## Favorites
......
...@@ -258,12 +258,43 @@ async function runLocalPlay(latest) { ...@@ -258,12 +258,43 @@ async function runLocalPlay(latest) {
async function promptForApp(options) { async function promptForApp(options) {
const inferred = options.inferred || inferAppFromActiveEditor(resolveWorkspacePath(getConfig().get('localEpmRoot', '/home/vano/eter/static2/eepm'))); const inferred = options.inferred || inferAppFromActiveEditor(resolveWorkspacePath(getConfig().get('localEpmRoot', '/home/vano/eter/static2/eepm')));
const fallback = getWorkspaceState(options.fallbackKey, getWorkspaceState('lastApp', '')); const fallback = getWorkspaceState(options.fallbackKey, getWorkspaceState('lastApp', ''));
const initialValue = inferred?.app || fallback;
if (inferred?.app) {
const choice = await vscode.window.showQuickPick([
{
label: `$(check) OK: ${inferred.app}`,
description: inferred.source,
action: 'ok'
},
{
label: '$(edit) Изменить имя...',
description: 'Открыть поле ввода',
action: 'edit'
},
{
label: '$(close) Отмена',
action: 'cancel'
}
], {
title: options.title,
placeHolder: `${options.prompt} (inferred from ${inferred.source})`
});
if (!choice || choice.action === 'cancel') {
return undefined;
}
if (choice.action === 'ok') {
return inferred.app;
}
}
return vscode.window.showInputBox({ return vscode.window.showInputBox({
title: options.title, title: options.title,
prompt: inferred prompt: inferred
? `${options.prompt} (inferred from ${inferred.source})` ? `${options.prompt} (inferred from ${inferred.source})`
: options.prompt, : options.prompt,
value: inferred?.app || fallback, value: initialValue,
placeHolder: 'rstudio' placeHolder: 'rstudio'
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment