Allow plugins to set the parent/predecessor of a new session (#3723)
This commit is contained in:
parent
6deb733d63
commit
71953e0fdf
6 changed files with 22 additions and 19 deletions
|
|
@ -17,7 +17,7 @@ import {
|
|||
SESSION_SEARCH_CLOSE
|
||||
} from '../constants/sessions';
|
||||
|
||||
export function addSession({uid, shell, pid, cols, rows, splitDirection}) {
|
||||
export function addSession({uid, shell, pid, cols, rows, splitDirection, activeUid}) {
|
||||
return (dispatch, getState) => {
|
||||
const {sessions} = getState();
|
||||
const now = Date.now();
|
||||
|
|
@ -29,7 +29,7 @@ export function addSession({uid, shell, pid, cols, rows, splitDirection}) {
|
|||
cols,
|
||||
rows,
|
||||
splitDirection,
|
||||
activeUid: sessions.activeUid,
|
||||
activeUid: activeUid ? activeUid : sessions.activeUid,
|
||||
now
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,14 +12,15 @@ import getRootGroups from '../selectors';
|
|||
import {setActiveSession, ptyExitSession, userExitSession} from './sessions';
|
||||
|
||||
function requestSplit(direction) {
|
||||
return () => (dispatch, getState) => {
|
||||
return activeUid => (dispatch, getState) => {
|
||||
dispatch({
|
||||
type: SESSION_REQUEST,
|
||||
effect: () => {
|
||||
const {ui} = getState();
|
||||
const {ui, sessions} = getState();
|
||||
rpc.emit('new', {
|
||||
splitDirection: direction,
|
||||
cwd: ui.cwd
|
||||
cwd: ui.cwd,
|
||||
activeUid: activeUid ? activeUid : sessions.activeUid
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
@ -37,7 +38,7 @@ export function resizeTermGroup(uid, sizes) {
|
|||
};
|
||||
}
|
||||
|
||||
export function requestTermGroup() {
|
||||
export function requestTermGroup(activeUid) {
|
||||
return (dispatch, getState) => {
|
||||
dispatch({
|
||||
type: TERM_GROUP_REQUEST,
|
||||
|
|
@ -46,7 +47,8 @@ export function requestTermGroup() {
|
|||
const {cwd} = ui;
|
||||
rpc.emit('new', {
|
||||
isNewGroup: true,
|
||||
cwd
|
||||
cwd,
|
||||
activeUid
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
12
lib/index.js
12
lib/index.js
|
|
@ -142,16 +142,16 @@ rpc.on('session search close', () => {
|
|||
store_.dispatch(sessionActions.closeSearch());
|
||||
});
|
||||
|
||||
rpc.on('termgroup add req', () => {
|
||||
store_.dispatch(termGroupActions.requestTermGroup());
|
||||
rpc.on('termgroup add req', ({activeUid}) => {
|
||||
store_.dispatch(termGroupActions.requestTermGroup(activeUid));
|
||||
});
|
||||
|
||||
rpc.on('split request horizontal', () => {
|
||||
store_.dispatch(termGroupActions.requestHorizontalSplit());
|
||||
rpc.on('split request horizontal', ({activeUid}) => {
|
||||
store_.dispatch(termGroupActions.requestHorizontalSplit(activeUid));
|
||||
});
|
||||
|
||||
rpc.on('split request vertical', () => {
|
||||
store_.dispatch(termGroupActions.requestVerticalSplit());
|
||||
rpc.on('split request vertical', ({activeUid}) => {
|
||||
store_.dispatch(termGroupActions.requestVerticalSplit(activeUid));
|
||||
});
|
||||
|
||||
rpc.on('reset fontSize req', () => {
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ const reducer = (state = initialState, action) => {
|
|||
cols: action.cols,
|
||||
rows: action.rows,
|
||||
uid: action.uid,
|
||||
shell: action.shell.split('/').pop(),
|
||||
shell: action.shell ? action.shell.split('/').pop() : null,
|
||||
pid: action.pid
|
||||
})
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue