Skip to content

Commit 9879746

Browse files
committed
Merge branch 'main' into feat/ssh-userpass
2 parents 51ce78a + 7d5389f commit 9879746

File tree

9 files changed

+99
-64
lines changed

9 files changed

+99
-64
lines changed

client/src/commands/run.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ import {
1212
} from "vscode";
1313
import type { BaseLanguageClient } from "vscode-languageclient";
1414

15+
import { basename, extname } from "path";
16+
1517
import { showResult } from "../components/ResultPanel";
1618
import {
1719
appendExecutionLogFn,
1820
appendSessionLogFn,
21+
setFileName,
1922
} from "../components/logViewer";
2023
import { sasDiagnostic } from "../components/logViewer/sasDiagnostics";
2124
import { SASCodeDocument } from "../components/utils/SASCodeDocument";
@@ -112,6 +115,9 @@ async function runCode(selected?: boolean, uri?: Uri) {
112115
session.onExecutionLogFn = onExecutionLogFn;
113116
session.onSessionLogFn = appendSessionLogFn;
114117

118+
const fileName = basename(codeDoc.getUri(), extname(codeDoc.getUri()));
119+
setFileName(fileName);
120+
115121
await session.setup();
116122

117123
await window.withProgress(
@@ -222,6 +228,9 @@ async function _runTask(
222228
);
223229
session.onSessionLogFn = appendSessionLogFn;
224230

231+
const fileName = basename(codeDoc.getUri(), extname(codeDoc.getUri()));
232+
setFileName(fileName);
233+
225234
messageEmitter.fire(`${l10n.t("Connecting to SAS session...")}\r\n`);
226235
!cancelled && (await session.setup(true));
227236

client/src/components/logViewer/index.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type { OnLogFn } from "../../connection";
1212
import { useLogStore, useRunStore } from "../../store";
1313
import { logSelectors, runSelectors } from "../../store/selectors";
1414
import {
15+
clearLogOnExecutionStart,
1516
showLogOnExecutionFinish,
1617
showLogOnExecutionStart,
1718
} from "../utils/settings";
@@ -20,6 +21,7 @@ const { setProducedExecutionLogOutput } = useLogStore.getState();
2021

2122
let outputChannel: OutputChannel;
2223
let data: string[] = [];
24+
let fileName = "";
2325

2426
export const legend = {
2527
tokenTypes: ["error", "warning", "note"],
@@ -66,9 +68,16 @@ export const appendLogToken = (type: string): void => {
6668
data.push(type);
6769
};
6870

71+
export const setFileName = (name: string) => {
72+
fileName = name;
73+
};
74+
6975
const appendLogLines: OnLogFn = (logs) => {
7076
if (!outputChannel) {
71-
outputChannel = window.createOutputChannel(l10n.t("SAS Log"), "sas-log");
77+
const name = clearLogOnExecutionStart()
78+
? l10n.t("SAS Log: {name}", { name: fileName })
79+
: l10n.t("SAS Log");
80+
outputChannel = window.createOutputChannel(name, "sas-log");
7281
}
7382
for (const line of logs) {
7483
appendLogToken(line.type);
@@ -100,6 +109,12 @@ useRunStore.subscribe(
100109
}
101110
} else if (isExecuting && !prevIsExecuting) {
102111
setProducedExecutionLogOutput(false);
112+
113+
if (clearLogOnExecutionStart() && outputChannel) {
114+
outputChannel.dispose();
115+
outputChannel = undefined;
116+
data = [];
117+
}
103118
}
104119
},
105120
);

client/src/components/logViewer/logParser.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@ import {
99
isSourceCodeLineAfterLineWrapping,
1010
} from "./ProblemProcessor";
1111

12-
export function parseLog(
13-
logs: LogLine[],
14-
logStartFlag: string,
15-
): Problem[] | null {
12+
export function parseLog(logs: LogLine[], logStartFlag: string): Problem[] {
1613
if (logs.length === 0 || logStartFlag.trim() === "") {
17-
return null;
14+
return [];
1815
}
1916

2017
// logs cleaning

client/src/components/utils/settings.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ export function showLogOnExecutionFinish(): boolean {
2626
return workspace.getConfiguration("SAS").get("log.showOnExecutionFinish");
2727
}
2828

29+
export function clearLogOnExecutionStart(): boolean {
30+
return workspace.getConfiguration("SAS").get("log.clearOnExecutionStart");
31+
}
32+
2933
export function isShowProblemsFromSASLogEnabled(): boolean {
3034
return workspace.getConfiguration("SAS").get("problems.log.enabled");
3135
}

package-lock.json

Lines changed: 53 additions & 57 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,12 @@
479479
"type": "boolean",
480480
"default": true,
481481
"description": "%configuration.SAS.log.showOnExecutionFinish%"
482+
},
483+
"SAS.log.clearOnExecutionStart": {
484+
"order": 9,
485+
"type": "boolean",
486+
"default": true,
487+
"description": "%configuration.SAS.log.clearOnExecutionStart%"
482488
}
483489
}
484490
}
@@ -1123,7 +1129,7 @@
11231129
"papaparse": "^5.4.1",
11241130
"path-browserify": "^1.0.1",
11251131
"prettier": "^3.3.3",
1126-
"sinon": "^18.0.0",
1132+
"sinon": "^19.0.2",
11271133
"ts-loader": "^9.5.1",
11281134
"ts-node": "^10.9.2",
11291135
"ts-sinon": "^2.0.2",

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"configuration.SAS.flowConversionMode": "Choose the conversion mode for notebooks",
5656
"configuration.SAS.flowConversionModeNode": "Convert each notebook cell to a node",
5757
"configuration.SAS.flowConversionModeSwimlane": "Convert each notebook cell to a swimlane",
58+
"configuration.SAS.log.clearOnExecutionStart": "Clear SAS Log when code execution starts",
5859
"configuration.SAS.log.showOnExecutionFinish": "Show SAS Log when code execution is finished",
5960
"configuration.SAS.log.showOnExecutionStart": "Show SAS Log when code execution starts",
6061
"configuration.SAS.problems.log.enabled": "Show problems from SAS log",

package.nls.zh-cn.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"configuration.SAS.flowConversionMode": "选择笔记本的转换模式",
5555
"configuration.SAS.flowConversionModeNode": "将每个笔记本单元转换为一个节点",
5656
"configuration.SAS.flowConversionModeSwimlane": "将每个笔记本单元转换为泳道",
57+
"configuration.SAS.log.clearOnExecutionStart": "代码执行开始时清空 SAS 日志",
5758
"configuration.SAS.log.showOnExecutionFinish": "代码执行完成时显示 SAS 日志",
5859
"configuration.SAS.log.showOnExecutionStart": "代码执行开始时显示 SAS 日志",
5960
"configuration.SAS.problems.log.enabled": "显示SAS日志中报告的问题",

website/docs/Configurations/sasLog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,9 @@ Example
3737
}
3838
}
3939
```
40+
41+
:::tip
42+
43+
To view the SAS log as a text file, click the `...` icon on the top right of the OUTPUT panel, and select `Open Output in Editor`.
44+
45+
:::

0 commit comments

Comments
 (0)