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:
@ -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 {
|
||||
|
@ -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;
|
||||
|
35
packages/vscode/src/fill/vscodeTextmate.ts
Normal file
35
packages/vscode/src/fill/vscodeTextmate.ts
Normal 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;
|
Reference in New Issue
Block a user