mirror of
https://github.com/atom/atom.git
synced 2026-02-06 20:55:33 -05:00
Add ability to move directionally across *all* visible panes
Prior to this change, the following commands successfully move between
panes in the workspace center, but they could not move between the the
panes in the workspace center and panes in the docks:
- window:focus-pane-above
- window:focus-pane-below
- window:focus-pane-on-left
- window:focus-pane-on-right
- window:move-active-item-to-pane-above
- window:move-active-item-to-pane-below
- window:move-active-item-to-pane-on-left
- window:move-active-item-to-pane-on-right
- window:copy-active-item-to-pane-above
- window:copy-active-item-to-pane-below
- window:copy-active-item-to-pane-on-left
- window:copy-active-item-to-pane-on-right
This commit updates these commands to work across all visible panes,
regardless of whether the pane is in the workspace center or a dock.
Summary of approach:
- Add tests for the `nearestVisiblePaneInDirection`, which provides the
core logic for the higher-level methods like `focusPaneViewAbove`,
`moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc.
- Test the generic logic extensively (i.e., the logic that is
independent of whether the given pane resides in the workspace
center or a dock)
- Also test the navigation between docks and the workspace center
- Since the core logic is tested in the new tests above, simplify the
tests for the higher-level methods (e.g., `focusPaneViewAbove`,
`moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid
unnecessary duplication.
- Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented
in terms of the existing `nearestPaneInDirection` method on
`PaneContainerElement` for now.
This commit is contained in:
@@ -57,16 +57,26 @@ class PaneContainerElement extends HTMLElement
|
||||
@model.moveActiveItemToPane(destPane)
|
||||
destPane.focus()
|
||||
|
||||
nearestPaneInDirection: (direction) ->
|
||||
nearestPaneInDirection: (direction, pane = null) ->
|
||||
distance = (pointA, pointB) ->
|
||||
x = pointB.x - pointA.x
|
||||
y = pointB.y - pointA.y
|
||||
Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2))
|
||||
|
||||
paneView = @model.getActivePane().getElement()
|
||||
pane = pane or atom.workspace.getActivePane()
|
||||
paneView = pane.getElement()
|
||||
box = @boundingBoxForPaneView(paneView)
|
||||
|
||||
paneViews = _.toArray(@querySelectorAll('atom-pane'))
|
||||
visiblePaneContainers = atom.workspace.getPaneContainers()
|
||||
.filter (container) =>
|
||||
isCenter = container == atom.workspace.getCenter()
|
||||
isCenter or container.isVisible()
|
||||
|
||||
visiblePanes = _.flatten(visiblePaneContainers.map (container) => container.getPanes())
|
||||
|
||||
paneViews = visiblePanes
|
||||
.map (otherPane) =>
|
||||
otherPane.getElement()
|
||||
.filter (otherPaneView) =>
|
||||
otherBox = @boundingBoxForPaneView(otherPaneView)
|
||||
switch direction
|
||||
|
||||
@@ -238,6 +238,11 @@ class WorkspaceElement extends HTMLElement {
|
||||
|
||||
moveActiveItemToPaneOnRight (params) { this.paneContainer.moveActiveItemToPaneOnRight(params) }
|
||||
|
||||
nearestVisiblePaneInDirection (direction, pane) {
|
||||
const paneContainerElement = pane.getContainer().getElement()
|
||||
return paneContainerElement.nearestPaneInDirection(direction, pane)
|
||||
}
|
||||
|
||||
runPackageSpecs () {
|
||||
const activePaneItem = this.model.getActivePaneItem()
|
||||
const activePath = activePaneItem && typeof activePaneItem.getPath === 'function' ? activePaneItem.getPath() : null
|
||||
|
||||
Reference in New Issue
Block a user