Get the extension URI from the ExtensionContext instead of vscode.extensions.getExtension("saoudrizwan.claude-dev") (#5688)

This commit is contained in:
Sarah Fortune authored and GitHub committed 2025-08-19 13:52:41 -07:00
1 parent 26ce4a31b6
commit cf52db8f49
3 files changed
+7 -11

No files matched your search

+2 -2
View File
@@ -14,7 +14,7 @@ const activeThemeSubscriptions = new Set<StreamingResponseHandler<String>>()
* @param requestId The ID of the request (passed by the gRPC handler)
*/
export async function subscribeToTheme(
_controller: Controller,
controller: Controller,
_request: EmptyRequest,
responseStream: StreamingResponseHandler<String>,
requestId?: string,
@@ -33,7 +33,7 @@ export async function subscribeToTheme(
}
// Send the current theme immediately upon subscription
const theme = await getTheme()
const theme = await getTheme(controller.context)
if (theme) {
try {
const themeEvent = String.create({
+1 -1
View File
@@ -132,7 +132,7 @@ export class VscodeWebviewProvider extends WebviewProvider implements vscode.Web
async (e) => {
if (e && e.affectsConfiguration("workbench.colorTheme")) {
// Send theme update via gRPC subscription
const theme = await getTheme()
const theme = await getTheme(this.context)
if (theme) {
await sendThemeEvent(JSON.stringify(theme))
}
+4 -8
View File
@@ -30,8 +30,8 @@ function parseThemeString(themeString: string | undefined): any {
return JSON.parse(themeString ?? "{}")
}
export async function getTheme() {
let currentTheme
export async function getTheme(context: vscode.ExtensionContext) {
let currentTheme: string | undefined
const colorTheme = vscode.workspace.getConfiguration("workbench").get<string>("colorTheme") || "Default Dark Modern"
try {
@@ -54,7 +54,7 @@ export async function getTheme() {
if (currentTheme === undefined && defaultThemes[colorTheme]) {
const filename = `${defaultThemes[colorTheme]}.json`
currentTheme = await fs.readFile(
path.join(getExtensionUri().fsPath, "src", "integrations", "theme", "default-themes", filename),
path.join(context.extensionUri.fsPath, "src", "integrations", "theme", "default-themes", filename),
"utf-8",
)
}
@@ -64,7 +64,7 @@ export async function getTheme() {
if (parsed.include) {
const includeThemeString = await fs.readFile(
path.join(getExtensionUri().fsPath, "src", "integrations", "theme", "default-themes", parsed.include),
path.join(context.extensionUri.fsPath, "src", "integrations", "theme", "default-themes", parsed.include),
"utf-8",
)
const includeTheme = parseThemeString(includeThemeString)
@@ -135,7 +135,3 @@ export function mergeJson(
}
}
}
function getExtensionUri(): vscode.Uri {
return vscode.extensions.getExtension("saoudrizwan.claude-dev")!.extensionUri
}