mirror of
https://github.com/open-goal/opengoal-vscode.git
synced 2024-10-19 20:47:37 -04:00
settings: write settings safely if they are unregistered (ie. vscode-icons)
This commit is contained in:
parent
c9c1a36f13
commit
6e9f4495fd
|
@ -1,4 +1,5 @@
|
||||||
import * as vscode from "vscode";
|
import * as vscode from "vscode";
|
||||||
|
import { getMainChannel } from "../context";
|
||||||
import { getConfig } from "./config";
|
import { getConfig } from "./config";
|
||||||
|
|
||||||
// Settings defined in `configurationDefaults` are not merged with user settings
|
// Settings defined in `configurationDefaults` are not merged with user settings
|
||||||
|
@ -58,11 +59,18 @@ export async function setVSIconAssociations() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await userConfig.update(
|
// Throws error if the user doesn't have these settings
|
||||||
"vsicons.associations.files",
|
try {
|
||||||
currentIconAssociations,
|
await userConfig.update(
|
||||||
vscode.ConfigurationTarget.Global
|
"vsicons.associations.files",
|
||||||
);
|
currentIconAssociations,
|
||||||
|
vscode.ConfigurationTarget.Global
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
getMainChannel().append(
|
||||||
|
`Failed to write icon configuration override - ${err}`
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Could not use colors because of - https://github.com/Microsoft/vscode/issues/32813
|
// Could not use colors because of - https://github.com/Microsoft/vscode/issues/32813
|
||||||
|
@ -275,9 +283,14 @@ export async function setTextmateColors() {
|
||||||
|
|
||||||
currentTokenColorCustomizations.textMateRules = newRules;
|
currentTokenColorCustomizations.textMateRules = newRules;
|
||||||
|
|
||||||
await userConfig.update(
|
// Throws error if the user doesn't have these settings
|
||||||
"editor.tokenColorCustomizations",
|
try {
|
||||||
currentTokenColorCustomizations,
|
await userConfig.update(
|
||||||
vscode.ConfigurationTarget.Global
|
"editor.tokenColorCustomizations",
|
||||||
);
|
currentTokenColorCustomizations,
|
||||||
|
vscode.ConfigurationTarget.Global
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
getMainChannel().append(`Failed to write textmate rule override - ${err}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
import * as vscode from "vscode";
|
import * as vscode from "vscode";
|
||||||
import { RecentFiles } from "./RecentFiles";
|
import { RecentFiles } from "./RecentFiles";
|
||||||
|
|
||||||
|
const channel = vscode.window.createOutputChannel("OpenGOAL");
|
||||||
let extensionContext: vscode.ExtensionContext;
|
let extensionContext: vscode.ExtensionContext;
|
||||||
let recentFiles: RecentFiles;
|
let recentFiles: RecentFiles;
|
||||||
|
|
||||||
|
@ -22,3 +23,7 @@ export function getRecentFiles() {
|
||||||
export function getExtensionContext() {
|
export function getExtensionContext() {
|
||||||
return extensionContext;
|
return extensionContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getMainChannel() {
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
|
@ -7,13 +7,11 @@ import {
|
||||||
import { PdfCustomProvider } from "./vendor/vscode-pdfviewer/pdfProvider";
|
import { PdfCustomProvider } from "./vendor/vscode-pdfviewer/pdfProvider";
|
||||||
import { switchFile } from "./utils/file-utils";
|
import { switchFile } from "./utils/file-utils";
|
||||||
import { activateDecompTools } from "./decomp/decomp-tools";
|
import { activateDecompTools } from "./decomp/decomp-tools";
|
||||||
import { initContext } from "./context";
|
import { getMainChannel, initContext } from "./context";
|
||||||
import { IRFoldingRangeProvider } from "./languages/ir2-folder";
|
import { IRFoldingRangeProvider } from "./languages/ir2-folder";
|
||||||
import { activateTypeCastTools } from "./decomp/type-caster";
|
import { activateTypeCastTools } from "./decomp/type-caster";
|
||||||
import { IRInlayHintsProvider } from "./languages/ir2-inlay-hinter";
|
import { IRInlayHintsProvider } from "./languages/ir2-inlay-hinter";
|
||||||
|
|
||||||
const channel = vscode.window.createOutputChannel("OpenGOAL");
|
|
||||||
|
|
||||||
export async function activate(context: vscode.ExtensionContext) {
|
export async function activate(context: vscode.ExtensionContext) {
|
||||||
try {
|
try {
|
||||||
// Init Context
|
// Init Context
|
||||||
|
@ -66,7 +64,10 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
// Start the LSP
|
// Start the LSP
|
||||||
lsp.activate(context);
|
lsp.activate(context);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
channel.append(`Failed to activate extension - ${err}`);
|
vscode.window.showErrorMessage(
|
||||||
|
"Failed to activate OpenGOAL extension, see logs for details"
|
||||||
|
);
|
||||||
|
getMainChannel().append(`Failed to activate extension - ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue