Skip to content

Commit

Permalink
Remove json-based snippets, handled by the server now. (#2945)
Browse files Browse the repository at this point in the history
* Remove json-based snippets, handled by the server now.
  • Loading branch information
sean-mcmanus authored Dec 28, 2018
1 parent f58af4f commit c727cec
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 202 deletions.
140 changes: 0 additions & 140 deletions Extension/cpp_snippets.json

This file was deleted.

17 changes: 1 addition & 16 deletions Extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -505,11 +505,6 @@
"title": "%c_cpp.command.navigate.title%",
"category": "C/C++"
},
{
"command": "C_Cpp.ToggleSnippets",
"title": "%c_cpp.command.toggleSnippets.title%",
"category": "C/C++"
},
{
"command": "C_Cpp.ToggleErrorSquiggles",
"title": "%c_cpp.command.toggleErrorSquiggles.title%",
Expand Down Expand Up @@ -1372,17 +1367,7 @@
"[c]": {
"editor.wordBasedSuggestions": false
}
},
"snippets": [
{
"language": "cpp",
"path": "./cpp_snippets.json"
},
{
"language": "c",
"path": "./cpp_snippets.json"
}
]
}
},
"scripts": {
"compile": "npm run vscode:prepublish",
Expand Down
1 change: 0 additions & 1 deletion Extension/package.nls.it.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"c_cpp.command.peekDeclaration.title": "Visualizza dichiarazione",
"c_cpp.command.switchHeaderSource.title": "Visualizza Header/Sorgente",
"c_cpp.command.navigate.title": "Naviga...",
"c_cpp.command.toggleSnippets.title": "Attiva/Disattiva frammenti di codice",
"c_cpp.command.toggleErrorSquiggles.title": "Attiva/Disattiva sottolineamento errori",
"c_cpp.command.toggleIncludeFallback.title": "Attiva/Disattiva motore di fallback IntelliSense negli errori di inclusione",
"c_cpp.command.toggleDimInactiveRegions.title": "Attiva/Disattiva colorazione regioni inattive",
Expand Down
1 change: 0 additions & 1 deletion Extension/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"c_cpp.command.peekDeclaration.title": "Peek declaration",
"c_cpp.command.switchHeaderSource.title": "Switch Header/Source",
"c_cpp.command.navigate.title": "Navigate...",
"c_cpp.command.toggleSnippets.title": "Toggle snippets",
"c_cpp.command.toggleErrorSquiggles.title": "Toggle error squiggles",
"c_cpp.command.toggleIncludeFallback.title": "Toggle IntelliSense engine fallback on include errors",
"c_cpp.command.toggleDimInactiveRegions.title": "Toggle inactive region colorization",
Expand Down
42 changes: 0 additions & 42 deletions Extension/src/LanguageServer/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@ function registerCommands(): void {
disposables.push(vscode.commands.registerCommand('C_Cpp.ConfigurationEdit', onEditConfiguration));
disposables.push(vscode.commands.registerCommand('C_Cpp.AddToIncludePath', onAddToIncludePath));
disposables.push(vscode.commands.registerCommand('C_Cpp.ToggleErrorSquiggles', onToggleSquiggles));
disposables.push(vscode.commands.registerCommand('C_Cpp.ToggleSnippets', onToggleSnippets));
disposables.push(vscode.commands.registerCommand('C_Cpp.ToggleIncludeFallback', onToggleIncludeFallback));
disposables.push(vscode.commands.registerCommand('C_Cpp.ToggleDimInactiveRegions', onToggleDimInactiveRegions));
disposables.push(vscode.commands.registerCommand('C_Cpp.ShowReleaseNotes', onShowReleaseNotes));
Expand Down Expand Up @@ -542,47 +541,6 @@ function onToggleSquiggles(): void {
settings.toggleSetting("errorSquiggles", "Enabled", "Disabled");
}

function onToggleSnippets(): void {
onActivationEvent();

// This will apply to all clients as it's a global toggle. It will require a reload.
const snippetsCatName: string = "Snippets";
let newPackageJson: any = util.getRawPackageJson();

if (newPackageJson.categories.findIndex(cat => cat === snippetsCatName) === -1) {
// Add the Snippet category and snippets node.

newPackageJson.categories.push(snippetsCatName);
newPackageJson.contributes.snippets = [{"language": "cpp", "path": "./cpp_snippets.json"}, {"language": "c", "path": "./cpp_snippets.json"}];

fs.writeFile(util.getPackageJsonPath(), util.stringifyPackageJson(newPackageJson), () => {
showReloadPrompt("Reload Window to finish enabling C++ snippets");
});

} else {
// Remove the category and snippets node.
let ndxCat: number = newPackageJson.categories.indexOf(snippetsCatName);
if (ndxCat !== -1) {
newPackageJson.categories.splice(ndxCat, 1);
}

delete newPackageJson.contributes.snippets;

fs.writeFile(util.getPackageJsonPath(), util.stringifyPackageJson(newPackageJson), () => {
showReloadPrompt("Reload Window to finish disabling C++ snippets");
});
}
}

function showReloadPrompt(msg: string): void {
let reload: string = "Reload";
vscode.window.showInformationMessage(msg, reload).then(value => {
if (value === reload) {
vscode.commands.executeCommand("workbench.action.reloadWindow");
}
});
}

function onToggleIncludeFallback(): void {
onActivationEvent();
// This only applies to the active client.
Expand Down
1 change: 0 additions & 1 deletion Extension/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class TemporaryCommandRegistrar {
"C_Cpp.ToggleErrorSquiggles",
"C_Cpp.ToggleIncludeFallback",
"C_Cpp.ToggleDimInactiveRegions",
"C_Cpp.ToggleSnippets",
"C_Cpp.ShowReleaseNotes",
"C_Cpp.ResetDatabase",
"C_Cpp.PauseParsing",
Expand Down
1 change: 0 additions & 1 deletion Extension/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ function rewriteManifest(): Promise<void> {
"onCommand:C_Cpp.ToggleErrorSquiggles",
"onCommand:C_Cpp.ToggleIncludeFallback",
"onCommand:C_Cpp.ToggleDimInactiveRegions",
"onCommand:C_Cpp.ToggleSnippets",
"onCommand:C_Cpp.ShowReleaseNotes",
"onCommand:C_Cpp.ResetDatabase",
"onCommand:C_Cpp.PauseParsing",
Expand Down

0 comments on commit c727cec

Please sign in to comment.