Archived
1
0

Fix syntax highlighting, process spawning, extensions, terminals (#22)

* Fix syntax highlighting, process spawning, extensions, terminals

* Replace colons in toISOString

* Move pathSets included in task
This commit is contained in:
Kyle Carberry
2019-01-28 11:14:06 -06:00
parent 9b1a635d63
commit b4798d1a48
31 changed files with 300 additions and 46 deletions

View File

@ -7,7 +7,11 @@
},
"dependencies": {
"iconv-lite": "^0.4.24",
"onigasm": "^2.2.1",
"spdlog": "^0.7.2",
"string-replace-loader": "^2.1.1"
},
"devDependencies": {
"vscode-textmate": "^4.0.1"
}
}

View File

@ -3,6 +3,7 @@ import * as paths from "./fill/paths";
import "./fill/storageDatabase";
import "./fill/windowsService";
import "./fill/environmentService";
import "./fill/vscodeTextmate";
import "./fill/dom";
import "./vscode.scss";
@ -22,18 +23,21 @@ export class Client extends IDEClient {
public readonly protocolPromise: Promise<Protocol>;
public protoResolve: ((protocol: Protocol) => void) | undefined;
private readonly pathSets: Promise<void>;
public constructor() {
super();
this.protocolPromise = new Promise((resolve): void => {
this.protoResolve = resolve;
});
this.sharedProcessData.then((data) => {
this.pathSets = this.sharedProcessData.then((data) => {
paths._paths.socketPath = data.socketPath;
process.env.VSCODE_LOGS = data.logPath;
});
this.initData.then((data) => {
paths._paths.appData = data.dataDirectory;
paths._paths.defaultUserData = data.dataDirectory;
process.env.SHELL = data.shell;
});
}
@ -53,7 +57,7 @@ export class Client extends IDEClient {
nodeCachedDataDir: data.tmpDirectory,
perfEntries: [],
_: [],
folderUri: URI.file(data.dataDirectory),
folderUri: URI.file(data.workingDirectory),
});
// TODO: Set notification service for retrying.
@ -92,7 +96,7 @@ export class Client extends IDEClient {
// bounded.set(enabled);
// });
this.clipboard.initialize();
}, this.initData);
}, this.initData, this.pathSets);
}
protected createUriFactory(): IURIFactory {

View File

@ -1,6 +1,7 @@
import * as cp from "child_process";
import { client } from "@coder/ide/src/fill/client";
import { EventEmitter } from "events";
import * as nodePty from "node-pty";
import { ChildProcess } from "@coder/protocol/src/browser/command";
type nodePtyType = typeof nodePty;
@ -10,38 +11,32 @@ type nodePtyType = typeof nodePty;
class Pty implements nodePty.IPty {
private readonly emitter: EventEmitter;
private readonly cp: ChildProcess;
public constructor(file: string, args: string[] | string, options: nodePty.IPtyForkOptions) {
this.emitter = new EventEmitter();
const session = wush.execute({
command: `${file} ${Array.isArray(args) ? args.join(" ") : args}`,
directory: options.cwd,
environment: {
...(options.env || {}),
TERM: "xterm-color",
this.cp = client.spawn(file, Array.isArray(args) ? args : [args], {
...options,
tty: {
columns: options.cols || 100,
rows: options.rows || 100,
},
size: options && options.cols && options.rows ? {
columns: options.cols,
rows: options.rows,
} : {
columns: 100,
rows: 100,
},
});
this.on("write", (data) => session.sendStdin(data));
this.on("kill", (exitCode) => session.close());
this.on("resize", (columns, rows) => session.setSize({ columns, rows }));
session.onStdout((data) => this.emitter.emit("data", data));
session.onStderr((data) => this.emitter.emit("data", data));
session.onDone((exitCode) => this.emitter.emit("exit", exitCode));
this.on("write", (d) => this.cp.send(d));
this.on("kill", (exitCode) => this.cp.kill(exitCode));
this.on("resize", (cols, rows) => this.cp.resize!({ columns: cols, rows }));
this.cp.stdout.on("data", (data) => this.emitter.emit("data", data));
this.cp.stderr.on("data", (data) => this.emitter.emit("data", data));
this.cp.on("exit", (code) => this.emitter.emit("exit", code));
}
public get pid(): number {
return 1;
return this.cp.pid!;
}
public get process(): string {
return "unknown";
return this.cp.title!;
}
public on(event: string, listener: (...args) => void): void {
@ -70,4 +65,4 @@ const ptyType: nodePtyType = {
};
exports = ptyType;
module.exports = ptyType;

View File

@ -0,0 +1,35 @@
import * as vscodeTextmate from "../../../../lib/vscode/node_modules/vscode-textmate";
const target = vscodeTextmate as typeof vscodeTextmate;
target.Registry = class Registry extends vscodeTextmate.Registry {
public constructor(opts: vscodeTextmate.RegistryOptions) {
super({
...opts,
getOnigLib: (): Promise<vscodeTextmate.IOnigLib> => {
return new Promise<vscodeTextmate.IOnigLib>((res, rej) => {
const onigasm = require('onigasm');
const wasmUrl = require('!!file-loader!onigasm/lib/onigasm.wasm');
return fetch(wasmUrl).then(resp => resp.arrayBuffer()).then(buffer => {
return onigasm.loadWASM(buffer);
}).then(() => {
res({
createOnigScanner: function (patterns) { return new onigasm.OnigScanner(patterns); },
createOnigString: function (s) { return new onigasm.OnigString(s); }
})
}).catch(reason => rej(reason));
});
},
});
}
}
enum StandardTokenType {
Other = 0,
Comment = 1,
String = 2,
RegEx = 4,
};
// Any needed here to override const
(<any>target).StandardTokenType = StandardTokenType;

View File

@ -43,9 +43,6 @@ module.exports = (env) => {
},
],
},
}, {
test: /\.wasm$/,
type: "javascript/auto",
}, {
// Ignore a bunch of file types we don't have loaders for. Also ignore
// test directories, some files with invalid JSON, and files we don't

View File

@ -70,6 +70,14 @@ loader-utils@^1.1.0:
emojis-list "^2.0.0"
json5 "^1.0.1"
lru-cache@^4.1.1:
version "4.1.5"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd"
integrity sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==
dependencies:
pseudomap "^1.0.2"
yallist "^2.1.2"
minimist@0.0.8:
version "0.0.8"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"
@ -87,11 +95,30 @@ mkdirp@^0.5.1:
dependencies:
minimist "0.0.8"
nan@^2.8.0:
nan@^2.10.0, nan@^2.8.0:
version "2.12.1"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.12.1.tgz#7b1aa193e9aa86057e3c7bbd0ac448e770925552"
integrity sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw==
onigasm@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/onigasm/-/onigasm-2.2.1.tgz#d56da809d63d3bb25510e8b8e447ffe98e56bebb"
integrity sha512-pa361CpVfsWOk0MQ1jLuJ1GvEJMHEHgZmaBpOIfBbvbp2crkDHacXB6mA4vgEfO7fL0OEMUSuZjX0Q9yTx6jTg==
dependencies:
lru-cache "^4.1.1"
oniguruma@^7.0.0:
version "7.0.2"
resolved "https://registry.yarnpkg.com/oniguruma/-/oniguruma-7.0.2.tgz#a5c922cf7066da1dbcc60f6385a90437a83f8d0b"
integrity sha512-zCsdNxTrrB4yVPMxhcIODGv1p4NVBu9WvsWnIGhMpu5djO4MQWXrC7YKjtza+OyoRqqgy27CqYWa1h5e2DDbig==
dependencies:
nan "^2.10.0"
pseudomap@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3"
integrity sha1-8FKijacOYYkX7wqKw0wa5aaChrM=
punycode@^2.1.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
@ -133,3 +160,15 @@ uri-js@^4.2.2:
integrity sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==
dependencies:
punycode "^2.1.0"
vscode-textmate@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/vscode-textmate/-/vscode-textmate-4.0.1.tgz#6c36f28e9059ce12bc34907f7a33ea43166b26a8"
integrity sha512-gHTXTj04TUgbjB8y7pkVwxOiuCuD6aU5gnFzIByQuqdgFpe/bJaaEIS4geGjbjWbd1XJh6zG1EthLfpNaXEqUw==
dependencies:
oniguruma "^7.0.0"
yallist@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52"
integrity sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=