Skip to content

Commit f850feb

Browse files
committed
Suggest JIRA ticket IDs with space only
1 parent 7aba9f2 commit f850feb

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/completions.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,26 @@ function getBranchIssueCompletion(
4545

4646
const completions: vscode.CompletionItem[] = [];
4747
completions.push(
48-
...getColonCompletion(firstLine, position.character, issueId),
48+
...getInitialCompletion(firstLine, position.character, issueId),
4949
);
5050
completions.push(
51-
...getBracketedCompletion(firstLine, position.character, issueId),
51+
...getCompletionInitialBracket(firstLine, position.character, issueId),
5252
);
5353

5454
return completions;
5555
}
5656

57-
function getColonCompletion(
57+
function getInitialCompletion(
5858
firstLine: string,
5959
cursorPosition: number,
6060
issueId: string,
6161
): vscode.CompletionItem[] {
6262
const issueIdColon = issueId + ": ";
63+
const issueIdSpace = issueId + " ";
6364
const bracketedIssueId = `[${issueId}] `;
6465

6566
if (firstLine.length === 0) {
66-
return [completion(issueIdColon, 0, 0)];
67+
return [completion(issueIdSpace, 0, 0), completion(issueIdColon, 0, 0)];
6768
}
6869

6970
if (cursorPosition !== firstLine.length) {
@@ -80,6 +81,7 @@ function getColonCompletion(
8081
}
8182

8283
return [
84+
completion(issueIdSpace, 0, typedSoFar.length - 1),
8385
completion(issueIdColon, 0, typedSoFar.length - 1),
8486
completion(bracketedIssueId, 0, typedSoFar.length - 1),
8587
];
@@ -88,7 +90,7 @@ function getColonCompletion(
8890
return [];
8991
}
9092

91-
function getBracketedCompletion(
93+
function getCompletionInitialBracket(
9294
firstLine: string,
9395
cursorPosition: number,
9496
issueId: string,

src/test/suite/completions.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,23 @@ function testLine(line: string, expectedCompletions: vscode.CompletionItem[]) {
2727

2828
suite("JIRA Issue ID Completions From Branch Name", () => {
2929
testLine("|", [
30+
completions.completion("JIRA-123 ", 0, 0),
3031
completions.completion("JIRA-123: ", 0, 0),
3132
completions.completion("[JIRA-123] ", 0, 0),
3233
]);
3334

3435
testLine("jir|", [
36+
completions.completion("JIRA-123 ", 0, 2),
3537
completions.completion("JIRA-123: ", 0, 2),
3638
completions.completion("[JIRA-123] ", 0, 2),
3739
]);
3840
testLine("JIR|", [
41+
completions.completion("JIRA-123 ", 0, 2),
3942
completions.completion("JIRA-123: ", 0, 2),
4043
completions.completion("[JIRA-123] ", 0, 2),
4144
]);
4245
testLine("jira-123|", [
46+
completions.completion("JIRA-123 ", 0, 7),
4347
completions.completion("JIRA-123: ", 0, 7),
4448
completions.completion("[JIRA-123] ", 0, 7),
4549
]);

0 commit comments

Comments
 (0)