Skip to content

Commit e9cb022

Browse files
committed
Fix cannot start child process;
Fix cannot output error message except `Error`; Change some local variables to global variable; Change `tsconfig.json` to remove comment in output; Change name of some variables.
1 parent 8a8f718 commit e9cb022

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/decorator.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const resultDecorationType = window.createTextEditorDecorationType({
1818
light: {},
1919
dark: {},
2020
});
21-
const colorMap = {
21+
const colorOfType = {
2222
'Value of Expression': 'green',
2323
'Console': '#457abb',
2424
'Error': 'red',
@@ -67,7 +67,7 @@ export default class Decorator {
6767
this.decorators.push(decorator);
6868
}
6969

70-
decorator.renderOptions.before.color = colorMap[result.type];
70+
decorator.renderOptions.before.color = colorOfType[result.type];
7171
decorator.renderOptions.before.contentText = ` ${result.text}`;
7272

7373
decorator.hoverMessage = new MarkdownString(result.type);
@@ -120,7 +120,7 @@ export default class Decorator {
120120
let out = data.value as string;
121121
let match: RegExpExecArray;
122122

123-
if ((match = /^(Error:\s.*)(?:\n\s*at\s)?/g.exec(out)) != null) {
123+
if ((match = /(\w*Error:\s.*)(?:\n\s*at\s)?/g.exec(out)) != null) {
124124
this.outputChannel.appendLine(` ${match[1]}\n\tat line ${data.line}`);
125125

126126
return { line: data.line, type: 'Error', text: match[1], value: match[1] };

src/repl-client.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import {
1818
import Decorator from "./decorator";
1919
import { spawn, ChildProcess } from "child_process";
2020

21+
const serverArguments = [`${__dirname}/repl-server.js`];
22+
23+
const stdioOptions = ['ignore', 'ignore', 'ignore', 'ipc'];
2124

2225
export default class ReplClient {
2326
private changeEventDisposable: Disposable;
@@ -96,9 +99,11 @@ export default class ReplClient {
9699

97100
async interpret() {
98101
try {
102+
if (!this.isClosed) this.close();
103+
99104
this.decorator.init(this.editor);
100105

101-
this.repl = spawn('node', [`${__dirname}/replServer.js`], { cwd: this.basePath, stdio: ['ignore', 'ignore', 'ignore', 'ipc'] })
106+
this.repl = spawn('node', serverArguments, { cwd: this.basePath, stdio: stdioOptions })
102107
.on('message', async result => await this.decorator.update(result))
103108
.on('error', err => this.outputChannel.appendLine(`[Repl Server] ${err.message}`));
104109

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"es6"
88
],
99
"sourceMap": true,
10-
"rootDir": "src"
10+
"rootDir": "src",
11+
"removeComments": true
1112
},
1213
"exclude": [
1314
"node_modules",

0 commit comments

Comments
 (0)