Rename jump-to-line package to go-to-line

This commit is contained in:
Kevin Sawicki
2013-01-25 12:52:10 -08:00
parent 8bf82d3aa1
commit 5524999946
9 changed files with 67 additions and 67 deletions

View File

@@ -1,12 +1,12 @@
DeferredAtomPackage = require 'deferred-atom-package'
module.exports =
class JumpToLinePackage extends DeferredAtomPackage
class GoToLinePackage extends DeferredAtomPackage
loadEvents:
'editor:jump-to-line': '.editor'
'editor:go-to-line': '.editor'
instanceClass: 'jump-to-line/lib/jump-to-line-view'
instanceClass: 'go-to-line/lib/go-to-line-view'
onLoadEvent: (event, instance) ->
instance.toggle(event.currentTargetView())

View File

@@ -1,6 +1,6 @@
'body':
'meta-l': 'editor:jump-to-line'
'.jump-to-line .mini.editor input':
'meta-l': 'editor:go-to-line'
'.go-to-line .mini.editor input':
'enter': 'core:confirm',
'escape': 'core:cancel'
'meta-w': 'core:cancel'

View File

@@ -4,12 +4,12 @@ $ = require 'jquery'
Point = require 'point'
module.exports =
class JumpToLineView extends View
class GoToLineView extends View
@activate: (rootView) -> new JumpToLineView(rootView)
@activate: (rootView) -> new GoToLineView(rootView)
@content: ->
@div class: 'jump-to-line', =>
@div class: 'go-to-line', =>
@subview 'miniEditor', new Editor(mini: true)
@div class: 'message', outlet: 'message'

View File

@@ -0,0 +1,51 @@
RootView = require 'root-view'
describe 'GoToLine', ->
[rootView, goToLine, editor] = []
beforeEach ->
rootView = new RootView(require.resolve('fixtures/sample.js'))
rootView.enableKeymap()
goToLine = atom.loadPackage("go-to-line").getInstance()
editor = rootView.getActiveEditor()
editor.setCursorBufferPosition([1,0])
afterEach ->
rootView.remove()
describe "when editor:go-to-line is triggered", ->
it "attaches to the root view", ->
expect(goToLine.hasParent()).toBeFalsy()
editor.trigger 'editor:go-to-line'
expect(goToLine.hasParent()).toBeTruthy()
describe "when entering a line number", ->
it "only allows 0-9 to be entered in the mini editor", ->
expect(goToLine.miniEditor.getText()).toBe ''
goToLine.miniEditor.textInput 'a'
expect(goToLine.miniEditor.getText()).toBe ''
goToLine.miniEditor.textInput '40'
expect(goToLine.miniEditor.getText()).toBe '40'
describe "when core:confirm is triggered", ->
describe "when a line number has been entered", ->
it "moves the cursor to the first character of the line", ->
goToLine.miniEditor.textInput '3'
goToLine.miniEditor.trigger 'core:confirm'
expect(editor.getCursorBufferPosition()).toEqual [2, 4]
describe "when no line number has been entered", ->
it "closes the view and does not update the cursor position", ->
editor.trigger 'editor:go-to-line'
expect(goToLine.hasParent()).toBeTruthy()
goToLine.miniEditor.trigger 'core:confirm'
expect(goToLine.hasParent()).toBeFalsy()
expect(editor.getCursorBufferPosition()).toEqual [1, 0]
describe "when core:cancel is triggered", ->
it "closes the view and does not update the cursor position", ->
editor.trigger 'editor:go-to-line'
expect(goToLine.hasParent()).toBeTruthy()
goToLine.miniEditor.trigger 'core:cancel'
expect(goToLine.hasParent()).toBeFalsy()
expect(editor.getCursorBufferPosition()).toEqual [1, 0]

View File

@@ -1,51 +0,0 @@
RootView = require 'root-view'
describe 'JumpToLine', ->
[rootView, jumpToLine, editor] = []
beforeEach ->
rootView = new RootView(require.resolve('fixtures/sample.js'))
rootView.enableKeymap()
jumpToLine = atom.loadPackage("jump-to-line").getInstance()
editor = rootView.getActiveEditor()
editor.setCursorBufferPosition([1,0])
afterEach ->
rootView.remove()
describe "when editor:jump-to-line is triggered", ->
it "attaches to the root view", ->
expect(jumpToLine.hasParent()).toBeFalsy()
editor.trigger 'editor:jump-to-line'
expect(jumpToLine.hasParent()).toBeTruthy()
describe "when entering a line number", ->
it "only allows 0-9 to be entered in the mini editor", ->
expect(jumpToLine.miniEditor.getText()).toBe ''
jumpToLine.miniEditor.textInput 'a'
expect(jumpToLine.miniEditor.getText()).toBe ''
jumpToLine.miniEditor.textInput '40'
expect(jumpToLine.miniEditor.getText()).toBe '40'
describe "when core:confirm is triggered", ->
describe "when a line number has been entered", ->
it "moves the cursor to the first character of the line", ->
jumpToLine.miniEditor.textInput '3'
jumpToLine.miniEditor.trigger 'core:confirm'
expect(editor.getCursorBufferPosition()).toEqual [2, 4]
describe "when no line number has been entered", ->
it "closes the view and does not update the cursor position", ->
editor.trigger 'editor:jump-to-line'
expect(jumpToLine.hasParent()).toBeTruthy()
jumpToLine.miniEditor.trigger 'core:confirm'
expect(jumpToLine.hasParent()).toBeFalsy()
expect(editor.getCursorBufferPosition()).toEqual [1, 0]
describe "when core:cancel is triggered", ->
it "closes the view and does not update the cursor position", ->
editor.trigger 'editor:jump-to-line'
expect(jumpToLine.hasParent()).toBeTruthy()
jumpToLine.miniEditor.trigger 'core:cancel'
expect(jumpToLine.hasParent()).toBeFalsy()
expect(editor.getCursorBufferPosition()).toEqual [1, 0]