Skip to content

Commit

Permalink
refactor(core): according to the change of main branch
Browse files Browse the repository at this point in the history
Signed-off-by: Shuguang Sun <[email protected]>
  • Loading branch information
ShuguangSun committed Jun 3, 2024
1 parent 6c99adb commit 8b41cef
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 8 deletions.
12 changes: 4 additions & 8 deletions client/src/connection/saspy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ import { ChildProcessWithoutNullStreams, spawn } from "child_process";
import { LogLineTypeEnum, RunResult } from "..";
import { getGlobalStorageUri } from "../../components/ExtensionContext";
import { updateStatusBarItem } from "../../components/StatusBarItem";
import {
extractOutputHtmlFileName,
wrapCodeWithOutputHtml,
} from "../../components/utils/sasCode";
import { Session } from "../session";
import { extractOutputHtmlFileName } from "../util";
// import { scriptContent } from "./script";
import { Config, LineCodes } from "./types";
import { saspyGetHtmlStyleValue } from "./util";

const LogLineTypes: LogLineTypeEnum[] = [
"normal",
Expand Down Expand Up @@ -80,9 +78,7 @@ export class SASPYSession extends Session {
%let rc = %sysfunc(dlgcdir("&workDir"));
run;
`;
const saspyWorkDirWithODS = wrapCodeWithOutputHtml(saspyWorkDir);
const saspyHtmlStyle =
saspyWorkDirWithODS.match(/style=([^ ]+) /)?.[1] ?? "Illuminate";
const saspyHtmlStyle = saspyGetHtmlStyleValue() ?? "Illuminate";

const cfgname =
this._config.cfgname?.length > 0 ? this._config.cfgname : "";
Expand Down Expand Up @@ -233,7 +229,7 @@ ${codeWithEnd}
*/
public cancel = async () => {
this._pollingForLogResults = false;
this._shellProcess.stdin.write("print(r'abc')\n", async (error) => {
this._shellProcess.stdin.write("%abort cancel;\n", async (error) => {
if (error) {
this._runReject(error);
}
Expand Down
33 changes: 33 additions & 0 deletions client/src/connection/saspy/util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright © 2024, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import {
ColorThemeKind,
window,
} from "vscode";

import { getHtmlStyle } from "../../components/utils/settings";

// To change the html style of SASPy
export const saspyGetHtmlStyleValue = (): string => {
const htmlStyleSetting = getHtmlStyle();

switch (htmlStyleSetting) {
case "(auto)":
switch (window.activeColorTheme.kind) {
case ColorThemeKind.Light:
return "Illuminate";
case ColorThemeKind.Dark:
return "Ignite";
case ColorThemeKind.HighContrast:
return "HighContrast";
case ColorThemeKind.HighContrastLight:
return "Illuminate";
default:
return "";
}
case "(server default)":
return "";
default:
return htmlStyleSetting;
}
}

0 comments on commit 8b41cef

Please sign in to comment.