mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-12-27 08:32:30 +03:00
Revert "🐛 Remove Gutter from ViewRegistry"
This reverts commit b0d93accf7
.
This commit is contained in:
parent
b04b0a8dc4
commit
c8f24d2358
@ -16,6 +16,9 @@ describe "CustomGutterComponent", ->
|
||||
decorationsWrapperNode = gutterComponent.getDomNode().children.item(0)
|
||||
expect(decorationsWrapperNode.classList.contains('custom-decorations')).toBe true
|
||||
|
||||
it "makes its view accessible from the view registry", ->
|
||||
expect(gutterComponent.getDomNode()).toBe atom.views.getView(gutter)
|
||||
|
||||
it "hides its DOM node when ::hideNode is called, and shows its DOM node when ::showNode is called", ->
|
||||
gutterComponent.hideNode()
|
||||
expect(gutterComponent.getDomNode().style.display).toBe 'none'
|
||||
|
@ -107,24 +107,22 @@ describe "GutterContainerComponent", ->
|
||||
|
||||
gutterContainerComponent.updateSync(testState)
|
||||
expect(gutterContainerComponent.getDomNode().children.length).toBe 2
|
||||
|
||||
initialCustomGutterNode1 = gutterContainerComponent.getDomNode().children.item(0)
|
||||
initialLineNumbersNode = gutterContainerComponent.getDomNode().children.item(1)
|
||||
expectedCustomGutterNode = gutterContainerComponent.getDomNode().children.item(0)
|
||||
expect(expectedCustomGutterNode).toBe atom.views.getView(customGutter1)
|
||||
expectedLineNumbersNode = gutterContainerComponent.getDomNode().children.item(1)
|
||||
expect(expectedLineNumbersNode).toBe atom.views.getView(lineNumberGutter)
|
||||
|
||||
# Add a gutter.
|
||||
customGutter2 = new Gutter(mockGutterContainer, {name: 'custom2', priority: -10})
|
||||
testState = buildTestState([customGutter1, customGutter2, lineNumberGutter])
|
||||
gutterContainerComponent.updateSync(testState)
|
||||
|
||||
expect(gutterContainerComponent.getDomNode().children.length).toBe 3
|
||||
|
||||
unchangedCustomGutterNode1 = gutterContainerComponent.getDomNode().children.item(0)
|
||||
insertedCustomGutterNode2 = gutterContainerComponent.getDomNode().children.item(1)
|
||||
repositionedLineNumbersNode = gutterContainerComponent.getDomNode().children.item(2)
|
||||
|
||||
expect(initialCustomGutterNode1).toBe(unchangedCustomGutterNode1)
|
||||
expect(initialLineNumbersNode).toBe(repositionedLineNumbersNode)
|
||||
expect(insertedCustomGutterNode2).toBeDefined()
|
||||
expectedCustomGutterNode1 = gutterContainerComponent.getDomNode().children.item(0)
|
||||
expect(expectedCustomGutterNode1).toBe atom.views.getView(customGutter1)
|
||||
expectedCustomGutterNode2 = gutterContainerComponent.getDomNode().children.item(1)
|
||||
expect(expectedCustomGutterNode2).toBe atom.views.getView(customGutter2)
|
||||
expectedLineNumbersNode = gutterContainerComponent.getDomNode().children.item(2)
|
||||
expect(expectedLineNumbersNode).toBe atom.views.getView(lineNumberGutter)
|
||||
|
||||
# Hide one gutter, reposition one gutter, remove one gutter; and add a new gutter.
|
||||
customGutter2.hide()
|
||||
@ -132,12 +130,10 @@ describe "GutterContainerComponent", ->
|
||||
testState = buildTestState([customGutter2, customGutter1, customGutter3])
|
||||
gutterContainerComponent.updateSync(testState)
|
||||
expect(gutterContainerComponent.getDomNode().children.length).toBe 3
|
||||
|
||||
repositionedCustomGutterNode2 = gutterContainerComponent.getDomNode().children.item(0)
|
||||
repositionedCustomGutterNode1 = gutterContainerComponent.getDomNode().children.item(1)
|
||||
insertedCustomGutterNode3 = gutterContainerComponent.getDomNode().children.item(2)
|
||||
|
||||
expect(initialCustomGutterNode1).toBe(repositionedCustomGutterNode1)
|
||||
expect(repositionedCustomGutterNode2).toBe(insertedCustomGutterNode2)
|
||||
expect(repositionedCustomGutterNode2.style.display).toBe('none')
|
||||
expect(insertedCustomGutterNode3).toBeDefined()
|
||||
expectedCustomGutterNode2 = gutterContainerComponent.getDomNode().children.item(0)
|
||||
expect(expectedCustomGutterNode2).toBe atom.views.getView(customGutter2)
|
||||
expect(expectedCustomGutterNode2.style.display).toBe 'none'
|
||||
expectedCustomGutterNode1 = gutterContainerComponent.getDomNode().children.item(1)
|
||||
expect(expectedCustomGutterNode1).toBe atom.views.getView(customGutter1)
|
||||
expectedCustomGutterNode3 = gutterContainerComponent.getDomNode().children.item(2)
|
||||
expect(expectedCustomGutterNode3).toBe atom.views.getView(customGutter3)
|
||||
|
@ -1,4 +1,4 @@
|
||||
{createGutterView, setDimensionsAndBackground} = require './gutter-component-helpers'
|
||||
{setDimensionsAndBackground} = require './gutter-component-helpers'
|
||||
|
||||
# This class represents a gutter other than the 'line-numbers' gutter.
|
||||
# The contents of this gutter may be specified by Decorations.
|
||||
@ -11,8 +11,10 @@ class CustomGutterComponent
|
||||
@decorationItemsById = {}
|
||||
@visible = true
|
||||
|
||||
@domNode = createGutterView(@gutter)
|
||||
@domNode = atom.views.getView(@gutter)
|
||||
@decorationsNode = @domNode.firstChild
|
||||
# Clear the contents in case the domNode is being reused.
|
||||
@decorationsNode.innerHTML = ''
|
||||
|
||||
getDomNode: ->
|
||||
@domNode
|
||||
|
@ -1,5 +1,5 @@
|
||||
_ = require 'underscore-plus'
|
||||
{createGutterView, setDimensionsAndBackground} = require './gutter-component-helpers'
|
||||
{setDimensionsAndBackground} = require './gutter-component-helpers'
|
||||
|
||||
WrapperDiv = document.createElement('div')
|
||||
|
||||
@ -11,8 +11,9 @@ class LineNumberGutterComponent
|
||||
@lineNumberNodesById = {}
|
||||
@visible = true
|
||||
|
||||
@domNode = createGutterView(@gutter)
|
||||
@domNode = atom.views.getView(@gutter)
|
||||
@lineNumbersNode = @domNode.firstChild
|
||||
@lineNumbersNode.innerHTML = ''
|
||||
|
||||
@domNode.addEventListener 'click', @onClick
|
||||
@domNode.addEventListener 'mousedown', @onMouseDown
|
||||
|
@ -2,6 +2,8 @@
|
||||
Grim = require 'grim'
|
||||
{Emitter, CompositeDisposable} = require 'event-kit'
|
||||
Serializable = require 'serializable'
|
||||
{createGutterView} = require './gutter-component-helpers'
|
||||
Gutter = require './gutter'
|
||||
Model = require './model'
|
||||
Pane = require './pane'
|
||||
PaneElement = require './pane-element'
|
||||
@ -60,6 +62,7 @@ class PaneContainer extends Model
|
||||
new PaneElement().initialize(model)
|
||||
atom.views.addViewProvider TextEditor, (model) ->
|
||||
new TextEditorElement().initialize(model)
|
||||
atom.views.addViewProvider(Gutter, createGutterView)
|
||||
|
||||
onDidChangeRoot: (fn) ->
|
||||
@emitter.on 'did-change-root', fn
|
||||
|
Loading…
Reference in New Issue
Block a user