Skip to content

Commit

Permalink
Merge pull request #117 from Coding/hackape/pane-tabGroup-fix
Browse files Browse the repository at this point in the history
❇️ open tab to newly created file
  • Loading branch information
hackape authored May 3, 2017
2 parents 1d5f8f2 + 444ec12 commit e3a93eb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
18 changes: 16 additions & 2 deletions app/commands/commandBindings/file.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* @flow weak */
import uniqueId from 'lodash/uniqueId'
import { bindActionCreators } from 'redux'
import store, { getState, dispatch } from '../../store'
import mobxStore from '../../mobxStore'
Expand Down Expand Up @@ -50,6 +50,18 @@ function createFolderAtPath (path) {
)
}

function openTabOfNewFile (path) {
TabActions.createTab({
id: uniqueId('tab_'),
type: 'editor',
title: path.split('/').pop(),
path: path,
content: {
body: '',
}
})
}

export default {
'file:new_file': (c) => {
const node = c.context
Expand All @@ -62,7 +74,9 @@ export default {
message: 'Enter the path for the new file.',
defaultValue,
selectionRange: [path.length, defaultValue.length]
}).then(createFile)
})
.then(createFile)
.then(openTabOfNewFile)
},
'file:new_folder': (c) => {
const node = c.context
Expand Down
4 changes: 1 addition & 3 deletions app/components/FileTree/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ export function openNode (node, shouldBeFolded = null, deep = false) {
}
} else {
const tabType = getTabType(node)
if (
getTabType(node) === 'TEXT'
) {
if (getTabType(node) === 'TEXT') {
api.readFile(node.path)
.then(data => {
dispatch(TabActions.createTab({
Expand Down

0 comments on commit e3a93eb

Please sign in to comment.