Skip to content

Commit 60dc986

Browse files
committed
xo comply
1 parent 5104e07 commit 60dc986

File tree

7 files changed

+32
-139
lines changed

7 files changed

+32
-139
lines changed

app/win/pane.js

+27-44
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
const initSession = require('../utils/init-session');
21
const {exec} = require('child_process');
3-
const Session = require('../session');
4-
2+
const initSession = require('../utils/init-session');
53

64
module.exports = class Pane {
75
constructor({rows, cols, cwd, shell, shellArgs, splitDirection, activeUid, uid, parent}, rpc, fn) {
@@ -31,9 +29,8 @@ module.exports = class Pane {
3129
uid,
3230
shell: session.shell,
3331
pid: session.pty.pid
34-
});
32+
});
3533
}
36-
console.log('uid: ', this.uid, 'childs:', this.childs.size);
3734
fn(this);
3835
});
3936
}
@@ -49,48 +46,43 @@ module.exports = class Pane {
4946
opts.uid = recorded.uid;
5047
opts.cwd = recorded.cwd;
5148
}
52-
new Pane(opts, this.rpc, pane => {
53-
this.childs.add(pane);
54-
win.sessions.set(pane.uid, pane);
55-
pane.session.on('data', data => {
56-
this.rpc.emit('session data', {uid: pane.uid, data});
57-
});
49+
this.childs.add(new Pane(opts, this.rpc, pane => {
50+
win.sessions.set(pane.uid, pane);
51+
pane.session.on('data', data => {
52+
this.rpc.emit('session data', {uid: pane.uid, data});
53+
});
5854

59-
pane.session.on('exit', () => {
60-
if (!pane.root) {
61-
pane.parent.childs.delete(pane);
62-
if (pane.childs.size >= 1) {
63-
console.log('curentPaneUid: ', pane.uid);
64-
pane.childs.forEach(child => {
65-
child.parent = pane.parent;
66-
pane.parent.childs.add(child);
67-
});
68-
console.log('parentUid: ', pane.parent.uid);
69-
console.log('uid: ', pane.parent.uid, 'childs:', pane.parent.childs.size);
70-
}
55+
pane.session.on('exit', () => {
56+
if (!pane.root) {
57+
pane.parent.childs.delete(pane);
58+
if (pane.childs.size >= 1) {
59+
pane.childs.forEach(child => {
60+
child.parent = pane.parent;
61+
pane.parent.childs.add(child);
62+
});
7163
}
72-
});
73-
if (recorded) {
74-
recorded.childs.forEach(pane => {
75-
this.rpc.emit('pane restore', {uid: recorded.uid, pane});
76-
});
7764
}
78-
});
65+
});
66+
if (recorded) {
67+
recorded.childs.forEach(pane => {
68+
this.rpc.emit('pane restore', {uid: recorded.uid, pane});
69+
});
70+
}
71+
}));
7972
}
8073

8174
lastChild() {
8275
let cpt = 0;
83-
let last = undefined;
76+
let last;
8477
this.childs.forEach(child => {
8578
cpt++;
86-
console.log('childUID: ',child.uid);
8779
if (cpt === this.childs.size) {
8880
last = child;
8981
}
9082
});
91-
return last;
83+
return last;
9284
}
93-
85+
9486
record(fn) {
9587
const pid = this.session.pty.pid;
9688
exec(`lsof -p ${pid} | grep cwd | tr -s ' ' | cut -d ' ' -f9-`, (err, cwd) => {
@@ -101,17 +93,8 @@ module.exports = class Pane {
10193
this.cwd = cwd;
10294
}
10395
});
104-
105-
let pane = {};
106-
if(this.root === true) {
107-
pane = {uid: this.uid, cwd: this.cwd, type: 'PANE', root: this.root, childs: []};
108-
} else {
109-
pane = {uid: this.uid, cwd: this.cwd, type: 'PANE', root: this.root, direction: this.direction, childs: []};
110-
}
111-
// if(!this.root) {
112-
// pane = {uid: this.uid, cwd: this.cwd, type: 'PANE', root: this.root, direction: this.direction, childs: []};
113-
// }
114-
// const pane = {uid: this.uid, cwd: this.cwd, type: 'PANE', root: this.root, direction: this.direction, childs: []};
96+
97+
const pane = {uid: this.uid, cwd: this.cwd, type: 'PANE', root: this.root, direction: this.direction, childs: []};
11598
this.childs.forEach(child => {
11699
child.record(state => {
117100
pane.childs.push(state);

app/win/record.js

-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ module.exports.load = function () {
3232
// when opening create a new window
3333
app.createWindow();
3434
}
35-
// app.createWindow();
36-
3735
// start save scheduler
3836
this.save(wins.get());
3937
};

app/win/split.js

-83
This file was deleted.

app/win/tab.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const initSession = require('../utils/init-session');
2-
const Split = require('./split');
31
const Pane = require('./pane');
42

53
module.exports = class Tab {
@@ -8,13 +6,13 @@ module.exports = class Tab {
86
this.window = window;
97
fn(this);
108
}
11-
9+
1210
onRoot({rows, cols, cwd, shell, shellArgs, uid}, recorded) {
1311
if (recorded && recorded.root) {
1412
uid = recorded.root.uid;
1513
cwd = recorded.root.cwd;
1614
}
17-
15+
1816
this.root = new Pane({rows, cols, cwd, shell, shellArgs, uid}, this.window.rpc, pane => {
1917
pane.root = true;
2018
this.window.sessions.set(pane.uid, pane);
@@ -37,7 +35,7 @@ module.exports = class Tab {
3735
}
3836
});
3937
}
40-
38+
4139
onRootUpdate(pane) {
4240
this.root.childs.delete(pane);
4341
pane.toRoot();
@@ -67,7 +65,7 @@ module.exports = class Tab {
6765
const tab = {id: this.id, type: 'TAB', root: undefined};
6866
this.root.record(state => {
6967
tab.root = state;
70-
});
68+
});
7169
fn(tab);
7270
}
7371

app/win/window.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ module.exports = class Window extends BrowserWindow {
198198

199199
onTab(opts, recorded) {
200200
const size = this.tabs.size;
201-
this.tabs.add(new Tab(size + 1, this, (tab) => {
201+
this.tabs.add(new Tab(size + 1, this, tab => {
202202
tab.onRoot(opts, recorded);
203203
}));
204204
}

lib/actions/term-groups.js

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ export function restorePane(uid, pane) {
4444
dispatch({
4545
type: TERM_GROUP_REQUEST,
4646
effect: () => {
47-
console.log(pane);
4847
rpc.emit('new split', {
4948
activeUid: uid,
5049
splitDirection: pane.direction,

lib/index.js

-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ rpc.on('termgroup restore req', ({tab}) => {
7373
});
7474

7575
rpc.on('pane restore', ({uid, pane}) => {
76-
console.log('called');
77-
console.log(pane);
7876
store_.dispatch(termGroupActions.restorePane(uid, pane));
7977
});
8078

0 commit comments

Comments
 (0)