Skip to content

Commit

Permalink
fix colour scheme bug
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterWone committed Sep 26, 2022
1 parent 725fabe commit c1c5ef9
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

### 0.10.4

- Fixed an issue preventing the selected colour scheme from being applied

### 0.10.1

- Fix broken asset path
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-print",
"displayName": "Print",
"description": "Rendered Markdown, coloured code.",
"version": "0.10.1",
"version": "0.10.4",
"icon": "assets/vscode-print-128.png",
"author": {
"name": "Peter Wone",
Expand Down
6 changes: 3 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ localize("FILE_LIST_DISABLED", "x");

let server: http.Server | undefined;
const testFlags = new Set<string>();
let colourScheme = vscode.workspace.getConfiguration("print", null).colourScheme;
if (captionByFilename[colourScheme]) {
if (captionByFilename[vscode.workspace.getConfiguration("print").colourScheme]) {
// legacy value, convert
vscode.workspace.getConfiguration("print", null).update("colourScheme", captionByFilename[colourScheme]);
let cbf = captionByFilename[vscode.workspace.getConfiguration("print").colourScheme];
vscode.workspace.getConfiguration("print").update("colourScheme", cbf);
}
const printSessions = new Map<string, PrintSession>();
let _gc: NodeJS.Timer;
Expand Down
9 changes: 6 additions & 3 deletions src/print-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import { defaultCss, filenameByCaption } from "./imports";
const defaultMarkdownCss: string = require("./css/default-markdown.css").default.toString();
const lineNumbersCss: string = require("./css/line-numbers.css").default.toString();
let settingsCss: string = require("./css/settings.css").default.toString();
const colourSchemeName: string = filenameByCaption[vscode.workspace.getConfiguration("print", null).colourScheme];
const colourSchemeCss: string = require(`highlight.js/styles/${colourSchemeName}.css`).default.toString();
const browserLaunchMap: any = { darwin: "open", linux: "xdg-open", win32: "start" };

export class PrintSession {
Expand Down Expand Up @@ -146,9 +144,14 @@ export class PrintSession {
logger.debug(`Responding to vsc-print.resource request for ${urlParts[3]} in session ${urlParts[1]}`);
switch (urlParts[3]) {
case "colour-scheme.css":
let colourScheme = vscode.workspace.getConfiguration("print").colourScheme;
let colourSchemeName: string = filenameByCaption[colourScheme];
logger.debug(`Loading colour scheme from ${colourSchemeName}`);
let colourSchemeCss: string = require(`highlight.js/styles/${colourSchemeName}.css`).default.toString();
response.writeHead(200, {
"Content-Type": "text/css; charset=utf-8",
"Content-Length": colourSchemeCss.length
"Content-Length": colourSchemeCss.length,
'Cache-Control': 'no-cache'
});
response.end(colourSchemeCss);
break;
Expand Down
17 changes: 17 additions & 0 deletions src/test/test-docs/some.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.IO.Compression;

#pragma warning disable 414, 3021

namespace MyApplication
{
[Obsolete("...")]
class Program : IInterface
{
public static List<int> JustDoIt(int count)
{
Span<int> numbers = stackalloc int[length];
Console.WriteLine($"Hello {Name}!");
return new List<int>(new int[] { 1, 2, 3 })
}
}
}

0 comments on commit c1c5ef9

Please sign in to comment.