Skip to content

Commit 4814540

Browse files
committed
Extract statements prompting window reload to a function
1 parent a43077a commit 4814540

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

src/extension.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,7 @@ function listener(previousConfiguration) {
3737
if (hasSemicolons !== previousConfiguration.get('semicolons')) {
3838
try {
3939
writeSnippets(snippets(hasSemicolons));
40-
41-
const action = 'Reload';
42-
vscode.window
43-
.showInformationMessage(
44-
`Reload window in order for change in extension \`${EXTENSION_ID}\` configuration to take effect.`,
45-
action
46-
)
47-
.then(selectedAction => {
48-
if (selectedAction === action) {
49-
vscode.commands.executeCommand('workbench.action.reloadWindow');
50-
}
51-
});
40+
promptToReloadWindow();
5241
} catch (error) {
5342
vscode.window.showErrorMessage(
5443
`Extension \`${EXTENSION_ID}\` failed to write snippets to the file.`
@@ -66,3 +55,19 @@ function writeSnippets(snippets) {
6655

6756
fs.writeFileSync(snippetsPath, JSON.stringify(snippets));
6857
}
58+
59+
/** Prompts user to reload editor window in order for configuration change to take effect. */
60+
function promptToReloadWindow() {
61+
const action = 'Reload';
62+
63+
vscode.window
64+
.showInformationMessage(
65+
`Reload window in order for change in extension \`${EXTENSION_ID}\` configuration to take effect.`,
66+
action
67+
)
68+
.then(selectedAction => {
69+
if (selectedAction === action) {
70+
vscode.commands.executeCommand('workbench.action.reloadWindow');
71+
}
72+
});
73+
}

0 commit comments

Comments
 (0)