Skip to content

Commit 653ca2c

Browse files
authored
feat: ステータスバーにクリックイベントを追加し、変換の有効/無効を選択可能にする (#429)
1 parent 971cfd6 commit 653ca2c

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed

src/extension.ts

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export const NUMERO_SIGN_CODE_POINT = 0x2116;
99
let statusBarItem: vscode.StatusBarItem;
1010

1111
export function activate(context: vscode.ExtensionContext) {
12+
setupStatusBarItem();
13+
1214
context.subscriptions.push(
1315
vscode.Disposable.from(
1416
vscode.commands.registerCommand(
@@ -45,10 +47,46 @@ export function activate(context: vscode.ExtensionContext) {
4547
vscode.workspace.onDidChangeConfiguration(() => {
4648
updateStatusBarItem(statusBarItem);
4749
}),
50+
51+
// StatusBarのクリックイベントを登録
52+
vscode.commands.registerCommand(
53+
"waveDashUnify.SelectEnableOrDisable",
54+
() => {
55+
const quickPick = vscode.window.createQuickPick();
56+
quickPick.items = [
57+
{
58+
label: "Enable convert",
59+
description: "Enable convert",
60+
},
61+
{
62+
label: "Disable convert",
63+
description: "Disable convert",
64+
},
65+
];
66+
67+
quickPick.onDidChangeSelection((selection) => {
68+
if (selection.length === 0) {
69+
return;
70+
}
71+
72+
const selectedItem = selection[0];
73+
74+
if (selectedItem.label === "Enable convert") {
75+
vscode.commands.executeCommand("waveDashUnify.enableConvert");
76+
} else if (selectedItem.label === "Disable convert") {
77+
vscode.commands.executeCommand("waveDashUnify.disableConvert");
78+
}
79+
80+
quickPick.hide();
81+
});
82+
83+
quickPick.onDidHide(() => quickPick.dispose());
84+
85+
quickPick.show();
86+
},
87+
),
4888
),
4989
);
50-
51-
setupStatusBarItem();
5290
}
5391

5492
/**
@@ -167,6 +205,7 @@ export function setupStatusBarItem() {
167205
);
168206

169207
statusBarItem.name = "Wave Dash Unify";
208+
statusBarItem.command = "waveDashUnify.SelectEnableOrDisable";
170209

171210
updateStatusBarItem(statusBarItem);
172211
}

src/test/suite/extension.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,5 +697,13 @@ suite("Extension Test Suite", () => {
697697
expectedTextWithFormat,
698698
"statusBarFormat: custom",
699699
);
700+
701+
vscode.window.showQuickPick(["OK"], {
702+
placeHolder: "Please check the status bar",
703+
});
700704
});
705+
706+
// TODO ステータスバーのクリック時に実行されるコマンドのテストを行う
707+
// test("status bar item click", () => {
708+
// });
701709
});

0 commit comments

Comments
 (0)