Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions src/codeHighlighter.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import json5 from 'json5';
import * as shiki from 'shiki';
import type { IShikiTheme, Theme } from 'shiki';
import type { IShikiTheme } from 'shiki';
import { Highlighter } from 'shiki';
import * as vscode from 'vscode';

declare const TextDecoder: any;

// Default themes use `include` option that shiki doesn't support
const defaultThemesMap = new Map<string, Theme>([
['Default Light+', 'light-plus'],
['Default Dark+', 'dark-plus'],
]);

function getCurrentThemePath(themeName: string): vscode.Uri | undefined {
for (const ext of vscode.extensions.all) {
const themes = ext.packageJSON.contributes && ext.packageJSON.contributes.themes;
Expand Down Expand Up @@ -87,9 +81,7 @@ export class CodeHighlighter {
let theme: string | IShikiTheme | undefined;

const currentThemeName = vscode.workspace.getConfiguration('workbench').get<string>('colorTheme');
if (currentThemeName && defaultThemesMap.has(currentThemeName)) {
theme = defaultThemesMap.get(currentThemeName);
} else if (currentThemeName) {
if (currentThemeName) {
const colorThemePath = getCurrentThemePath(currentThemeName);
if (colorThemePath) {
theme = await shiki.loadTheme(colorThemePath.fsPath);
Expand Down