Merge pull request #16428 from ernesto28/resize-pane

Resize pane
This commit is contained in:
Antonio Scandurra
2018-03-09 08:38:44 +01:00
committed by GitHub
2 changed files with 37 additions and 2 deletions

View File

@@ -237,3 +237,30 @@ describe "PaneContainerElement", ->
atom.commands.dispatch(rightPane.getElement(), 'pane:decrease-size')
expect(leftPane.getFlexScale()).toBe 1/1.1
expect(rightPane.getFlexScale()).toBe 1/1.1
describe "when only a single pane is present", ->
[singlePane] = []
beforeEach ->
container = new PaneContainer(params)
singlePane = container.getActivePane()
describe "when pane:increase-size is triggered", ->
it "does not increases the size of the pane", ->
expect(singlePane.getFlexScale()).toBe 1
atom.commands.dispatch(singlePane.getElement(), 'pane:increase-size')
expect(singlePane.getFlexScale()).toBe 1
atom.commands.dispatch(singlePane.getElement(), 'pane:increase-size')
expect(singlePane.getFlexScale()).toBe 1
describe "when pane:decrease-size is triggered", ->
it "does not decreases the size of the pane", ->
expect(singlePane.getFlexScale()).toBe 1
atom.commands.dispatch(singlePane.getElement(), 'pane:decrease-size')
expect(singlePane.getFlexScale()).toBe 1
atom.commands.dispatch(singlePane.getElement(), 'pane:decrease-size')
expect(singlePane.getFlexScale()).toBe 1

View File

@@ -155,9 +155,17 @@ class Pane {
getFlexScale () { return this.flexScale }
increaseSize () { this.setFlexScale(this.getFlexScale() * 1.1) }
increaseSize () {
if (this.getContainer().getPanes().length > 1) {
this.setFlexScale(this.getFlexScale() * 1.1)
}
}
decreaseSize () { this.setFlexScale(this.getFlexScale() / 1.1) }
decreaseSize () {
if (this.getContainer().getPanes().length > 1) {
this.setFlexScale(this.getFlexScale() / 1.1)
}
}
/*
Section: Event Subscription