Skip to content

Commit f7e8fad

Browse files
committed
Fix syntax highlighting, process spawning, extensions, terminals (#22)
* Fix syntax highlighting, process spawning, extensions, terminals * Replace colons in toISOString * Move pathSets included in task
1 parent c4de41d commit f7e8fad

31 files changed

+300
-46
lines changed

packages/ide/src/fill/os.ts

+10
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ class OS {
3333
this._tmpdir = data.tmpDirectory;
3434
}
3535

36+
public platform(): NodeJS.Platform {
37+
if (navigator.appVersion.indexOf("Win") != -1) {
38+
return "win32";
39+
}
40+
if (navigator.appVersion.indexOf("Mac") != -1) {
41+
return "darwin";
42+
}
43+
return "linux";
44+
}
45+
3646
}
3747

3848
export = new OS();

packages/protocol/src/browser/client.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export class Client {
161161
* @param options Options to execute for the command
162162
*/
163163
public spawn(command: string, args: string[] = [], options?: SpawnOptions): ChildProcess {
164-
return this.doSpawn(command, args, options, false);
164+
return this.doSpawn(command, args, options, false, false);
165165
}
166166

167167
/**
@@ -272,6 +272,7 @@ export class Client {
272272
tmpDirectory: init.getTmpDirectory(),
273273
workingDirectory: init.getWorkingDirectory(),
274274
os: opSys,
275+
shell: init.getShell(),
275276
};
276277
this.initDataEmitter.emit(this._initData);
277278
} else if (message.hasEvalDone()) {
@@ -316,7 +317,14 @@ export class Client {
316317
if (!s) {
317318
return;
318319
}
319-
s.pid = message.getIdentifySession()!.getPid();
320+
const pid = message.getIdentifySession()!.getPid();
321+
if (typeof pid !== "undefined") {
322+
s.pid = pid;
323+
}
324+
const title = message.getIdentifySession()!.getTitle();
325+
if (typeof title !== "undefined") {
326+
s.title = title;
327+
}
320328
} else if (message.hasConnectionEstablished()) {
321329
const c = this.connections.get(message.getConnectionEstablished()!.getId());
322330
if (!c) {
@@ -347,6 +355,7 @@ export class Client {
347355
} else if (message.hasSharedProcessActive()) {
348356
this.sharedProcessActiveEmitter.emit({
349357
socketPath: message.getSharedProcessActive()!.getSocketPath(),
358+
logPath: message.getSharedProcessActive()!.getLogPath(),
350359
});
351360
} else if (message.hasServerEstablished()) {
352361
const s = this.servers.get(message.getServerEstablished()!.getId());

packages/protocol/src/browser/command.ts

+10
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export interface ChildProcess {
2626

2727
readonly killed?: boolean;
2828
readonly pid: number | undefined;
29+
readonly title?: string;
2930

3031
kill(signal?: string): void;
3132

@@ -45,6 +46,7 @@ export class ServerProcess extends events.EventEmitter implements ChildProcess {
4546
public readonly stderr = new stream.Readable({ read: (): boolean => true });
4647

4748
private _pid: number | undefined;
49+
private _title: string | undefined;
4850
private _killed: boolean = false;
4951
private _connected: boolean = false;
5052

@@ -69,6 +71,14 @@ export class ServerProcess extends events.EventEmitter implements ChildProcess {
6971
this._connected = true;
7072
}
7173

74+
public get title(): string | undefined {
75+
return this._title;
76+
}
77+
78+
public set title(title: string | undefined) {
79+
this._title = title;
80+
}
81+
7282
public get connected(): boolean {
7383
return this._connected;
7484
}

packages/protocol/src/browser/modules/fs.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export class FS {
113113
}
114114

115115
public createWriteStream = (): void => {
116-
throw new Error("not implemented");
116+
throw new Error("createWriteStream not implemented");
117117
}
118118

119119
public exists = (path: fs.PathLike, callback: (exists: boolean) => void): void => {

packages/protocol/src/common/connection.ts

+2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ export interface InitData {
2020
readonly workingDirectory: string;
2121
readonly homeDirectory: string;
2222
readonly tmpDirectory: string;
23+
readonly shell: string;
2324
}
2425

2526
export interface ISharedProcessData {
2627
readonly socketPath: string;
28+
readonly logPath: string;
2729
}

packages/protocol/src/node/command.ts

+24-1
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,39 @@ export const handleNewSession = (connection: SendableConnection, newSession: New
3535
]);
3636

3737
let process: Process;
38+
let processTitle: string | undefined;
3839

3940
const env: { [key: string]: string } = {};
4041
newSession.getEnvMap().forEach((value, key) => {
4142
env[key] = value;
4243
});
4344
if (newSession.getTtyDimensions()) {
4445
// Spawn with node-pty
45-
process = nodePty.spawn(newSession.getCommand(), newSession.getArgsList(), {
46+
const ptyProc = nodePty.spawn(newSession.getCommand(), newSession.getArgsList(), {
4647
cols: newSession.getTtyDimensions()!.getWidth(),
4748
rows: newSession.getTtyDimensions()!.getHeight(),
4849
cwd: newSession.getCwd(),
4950
env,
5051
});
52+
53+
const timer = setInterval(() => {
54+
if (ptyProc.process !== processTitle) {
55+
processTitle = ptyProc.process;
56+
const id = new IdentifySessionMessage();
57+
id.setId(newSession.getId());
58+
id.setTitle(processTitle);
59+
const sm = new ServerMessage();
60+
sm.setIdentifySession(id);
61+
connection.send(sm.serializeBinary());
62+
}
63+
}, 200);
64+
65+
ptyProc.on("exit", () => {
66+
clearTimeout(timer);
67+
});
68+
69+
process = ptyProc;
70+
processTitle = ptyProc.process;
5171
} else {
5272
const options = {
5373
cwd: newSession.getCwd(),
@@ -129,6 +149,9 @@ export const handleNewSession = (connection: SendableConnection, newSession: New
129149
const id = new IdentifySessionMessage();
130150
id.setId(newSession.getId());
131151
id.setPid(process.pid);
152+
if (processTitle) {
153+
id.setTitle(processTitle);
154+
}
132155
const sm = new ServerMessage();
133156
sm.setIdentifySession(id);
134157
connection.send(sm.serializeBinary());

packages/protocol/src/node/server.ts

+3
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ export class Server {
8686
throw new Error(`unrecognized platform "${platform}"`);
8787
}
8888
initMsg.setOperatingSystem(operatingSystem);
89+
if (process.env.SHELL) {
90+
initMsg.setShell(process.env.SHELL);
91+
}
8992
const srvMsg = new ServerMessage();
9093
srvMsg.setInit(initMsg);
9194
connection.send(srvMsg.serializeBinary());

packages/protocol/src/proto/client.proto

+1
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,5 @@ message WorkingInitMessage {
6060
Mac = 2;
6161
}
6262
OperatingSystem operating_system = 5;
63+
string shell = 6;
6364
}

packages/protocol/src/proto/client_pb.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,9 @@ export class WorkingInitMessage extends jspb.Message {
253253
getOperatingSystem(): WorkingInitMessage.OperatingSystem;
254254
setOperatingSystem(value: WorkingInitMessage.OperatingSystem): void;
255255

256+
getShell(): string;
257+
setShell(value: string): void;
258+
256259
serializeBinary(): Uint8Array;
257260
toObject(includeInstance?: boolean): WorkingInitMessage.AsObject;
258261
static toObject(includeInstance: boolean, msg: WorkingInitMessage): WorkingInitMessage.AsObject;
@@ -270,6 +273,7 @@ export namespace WorkingInitMessage {
270273
dataDirectory: string,
271274
workingDirectory: string,
272275
operatingSystem: WorkingInitMessage.OperatingSystem,
276+
shell: string,
273277
}
274278

275279
export enum OperatingSystem {

packages/protocol/src/proto/client_pb.js

+28-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/protocol/src/proto/command.proto

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ message SessionDoneMessage {
3535
int64 exit_status = 2;
3636
}
3737

38-
// Identifies a session with a PID.
38+
// Identifies a session with a PID and a title.
39+
// Can be sent multiple times when title changes.
3940
message IdentifySessionMessage {
4041
uint64 id = 1;
4142
uint64 pid = 2;
43+
string title = 3;
4244
}
4345

4446
// Writes data to a session.

packages/protocol/src/proto/command_pb.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ export class IdentifySessionMessage extends jspb.Message {
118118
getPid(): number;
119119
setPid(value: number): void;
120120

121+
getTitle(): string;
122+
setTitle(value: string): void;
123+
121124
serializeBinary(): Uint8Array;
122125
toObject(includeInstance?: boolean): IdentifySessionMessage.AsObject;
123126
static toObject(includeInstance: boolean, msg: IdentifySessionMessage): IdentifySessionMessage.AsObject;
@@ -132,6 +135,7 @@ export namespace IdentifySessionMessage {
132135
export type AsObject = {
133136
id: number,
134137
pid: number,
138+
title: string,
135139
}
136140
}
137141

packages/protocol/src/proto/command_pb.js

+28-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/protocol/src/proto/vscode.proto

+1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ syntax = "proto3";
33
// Sent when a shared process becomes active
44
message SharedProcessActiveMessage {
55
string socket_path = 1;
6+
string log_path = 2;
67
}

packages/protocol/src/proto/vscode_pb.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ export class SharedProcessActiveMessage extends jspb.Message {
77
getSocketPath(): string;
88
setSocketPath(value: string): void;
99

10+
getLogPath(): string;
11+
setLogPath(value: string): void;
12+
1013
serializeBinary(): Uint8Array;
1114
toObject(includeInstance?: boolean): SharedProcessActiveMessage.AsObject;
1215
static toObject(includeInstance: boolean, msg: SharedProcessActiveMessage): SharedProcessActiveMessage.AsObject;
@@ -20,6 +23,7 @@ export class SharedProcessActiveMessage extends jspb.Message {
2023
export namespace SharedProcessActiveMessage {
2124
export type AsObject = {
2225
socketPath: string,
26+
logPath: string,
2327
}
2428
}
2529

0 commit comments

Comments
 (0)