Skip to content

Commit 2bc6122

Browse files
committed
feat: add close on blur setting
1 parent f99d590 commit 2bc6122

File tree

7 files changed

+23
-0
lines changed

7 files changed

+23
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ Set logging level for extension
7373

7474
- `gitWorktree.worktree.loggingLevel`: Info
7575

76+
Should we close prompts when user loses focus
77+
78+
- `gitWorktree.worktree.closeInputOnBlur`: True
79+
7680
### Clone Settings
7781

7882
Set the name of the folder the bare repository contents will be push into

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@
101101
"Warn logging level",
102102
"Info logging level"
103103
]
104+
},
105+
"gitWorktree.worktree.closeInputOnBlur": {
106+
"type": "boolean",
107+
"default": true,
108+
"description": "Should we close input automatically when a user switches focus"
104109
}
105110
}
106111
},

src/commands/add.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export const add = async () => {
4545
[createWorktreeOption, ...filteredBranches],
4646
{
4747
placeHolder: 'Create new worktree or select remote branch',
48+
ignoreFocusOut: settings.shouldCloseOnBlur,
4849
}
4950
);
5051
if (!branch)
@@ -68,6 +69,7 @@ export const add = async () => {
6869

6970
let trackingBranch = await window.showQuickPick(remoteBranches, {
7071
placeHolder: 'Select remote branch to track',
72+
ignoreFocusOut: settings.shouldCloseOnBlur,
7173
});
7274

7375
worktree = await addNewWorktree(newBranch, trackingBranch);

src/commands/clone.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const clone = async () => {
1818
const cloneUrl = await window.showInputBox({
1919
placeHolder: 'Git repository url',
2020
prompt: 'Please enter a valid url to clone',
21+
ignoreFocusOut: settings.shouldCloseOnBlur,
2122
});
2223
if (!cloneUrl)
2324
return showUserMessage('Warn', 'Aborted as no url was given');
@@ -40,6 +41,7 @@ export const clone = async () => {
4041
const newRepoName = await window.showInputBox({
4142
placeHolder: 'Repository name',
4243
prompt: 'Enter new name for repository',
44+
ignoreFocusOut: settings.shouldCloseOnBlur,
4345
value: repoName,
4446
validateInput: async (value) => {
4547
const text = value?.trim();

src/config/settings.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ const openOnClone = getVSCodeSetting(
2121
noYesWindowOptions.yes
2222
);
2323

24+
const shouldCloseOnBlur = getVSCodeSetting(
25+
'gitWorktree.worktree.closeInputOnBlur',
26+
true
27+
);
28+
2429
// Project
2530
const shouldOpenOnProject = getVSCodeSetting(
2631
'gitWorktree.worktree.openOnProject',
@@ -79,6 +84,7 @@ const shouldRemoveMultiple = getVSCodeSetting(
7984
export default {
8085
shouldPushBranchAutomatically,
8186
loggingLevel,
87+
shouldCloseOnBlur,
8288

8389
// Clone
8490
cloneBaseDirectory,

src/helpers/vscode.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export const getUniqueWorktreeName = async ({
9191
return window.showInputBox({
9292
placeHolder,
9393
prompt,
94+
ignoreFocusOut: settings.shouldCloseOnBlur,
9495
value,
9596
validateInput: async (value) => {
9697
const text = value?.trim();

src/helpers/worktree/selectWorktree.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { IWorktree } from '#/@types/worktree';
2+
import settings from '#/src/config/settings';
23
import { window } from 'vscode';
34

45
export const selectWorktree = async <T extends boolean = false>(
@@ -20,6 +21,7 @@ export const selectWorktree = async <T extends boolean = false>(
2021
const worktree = await window.showQuickPick(items, {
2122
matchOnDetail: true,
2223
canPickMany,
24+
ignoreFocusOut: settings.shouldCloseOnBlur,
2325
});
2426

2527
if (!worktree) return;
@@ -30,6 +32,7 @@ export const selectWorktree = async <T extends boolean = false>(
3032
const worktree = await window.showQuickPick(items, {
3133
matchOnDetail: true,
3234
canPickMany,
35+
ignoreFocusOut: settings.shouldCloseOnBlur,
3336
});
3437

3538
if (!worktree) return;

0 commit comments

Comments
 (0)