Skip to content

Commit e3a93eb

Browse files
authored
Merge pull request #117 from Coding/hackape/pane-tabGroup-fix
❇️ open tab to newly created file
2 parents 1d5f8f2 + 444ec12 commit e3a93eb

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

app/commands/commandBindings/file.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* @flow weak */
1+
import uniqueId from 'lodash/uniqueId'
22
import { bindActionCreators } from 'redux'
33
import store, { getState, dispatch } from '../../store'
44
import mobxStore from '../../mobxStore'
@@ -50,6 +50,18 @@ function createFolderAtPath (path) {
5050
)
5151
}
5252

53+
function openTabOfNewFile (path) {
54+
TabActions.createTab({
55+
id: uniqueId('tab_'),
56+
type: 'editor',
57+
title: path.split('/').pop(),
58+
path: path,
59+
content: {
60+
body: '',
61+
}
62+
})
63+
}
64+
5365
export default {
5466
'file:new_file': (c) => {
5567
const node = c.context
@@ -62,7 +74,9 @@ export default {
6274
message: 'Enter the path for the new file.',
6375
defaultValue,
6476
selectionRange: [path.length, defaultValue.length]
65-
}).then(createFile)
77+
})
78+
.then(createFile)
79+
.then(openTabOfNewFile)
6680
},
6781
'file:new_folder': (c) => {
6882
const node = c.context

app/components/FileTree/actions.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ export function openNode (node, shouldBeFolded = null, deep = false) {
2525
}
2626
} else {
2727
const tabType = getTabType(node)
28-
if (
29-
getTabType(node) === 'TEXT'
30-
) {
28+
if (getTabType(node) === 'TEXT') {
3129
api.readFile(node.path)
3230
.then(data => {
3331
dispatch(TabActions.createTab({

0 commit comments

Comments
 (0)