mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Rename jump-to-line package to go-to-line
This commit is contained in:
@@ -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())
|
||||
@@ -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'
|
||||
@@ -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'
|
||||
|
||||
51
src/packages/go-to-line/spec/go-to-line-spec.coffee
Normal file
51
src/packages/go-to-line/spec/go-to-line-spec.coffee
Normal 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]
|
||||
@@ -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]
|
||||
Reference in New Issue
Block a user