Rename Editor::joinLine to ::joinLines

It acts on multiple lines, and in a quick survey of the literature I see
Sublime docs referring to it as "join lines" as well.
This commit is contained in:
Nathan Sobo 2014-02-25 12:52:13 -08:00
parent 9473039a0b
commit aa04589dd2
8 changed files with 14 additions and 16 deletions

View File

@ -133,7 +133,7 @@
'ctrl-cmd-up': 'editor:move-line-up'
'ctrl-cmd-down': 'editor:move-line-down'
'cmd-/': 'editor:toggle-line-comments'
'cmd-j': 'editor:join-line'
'cmd-j': 'editor:join-lines'
'cmd-D': 'editor:duplicate-line'
'cmd-L': 'editor:split-selections-into-lines'

View File

@ -80,7 +80,7 @@
'ctrl-up': 'editor:move-line-up'
'ctrl-down': 'editor:move-line-down'
'ctrl-/': 'editor:toggle-line-comments'
'ctrl-j': 'editor:join-line'
'ctrl-j': 'editor:join-lines'
'ctrl-D': 'editor:duplicate-line'
'ctrl-alt-[': 'editor:fold-current-row'

View File

@ -66,7 +66,7 @@
{ label: 'Move Line Down', command: 'editor:move-line-down' }
{ label: 'Duplicate Line', command: 'editor:duplicate-line' }
{ label: 'Delete Line', command: 'editor:delete-line' }
{ label: 'Join Lines', command: 'editor:join-line' }
{ label: 'Join Lines', command: 'editor:join-lines' }
]
}
{

View File

@ -45,7 +45,7 @@
{ label: 'Move Line &Down', command: 'editor:move-line-down' }
{ label: 'Du&plicate Line', command: 'editor:duplicate-line' }
{ label: 'D&elete Line', command: 'editor:delete-line' }
{ label: '&Join Lines', command: 'editor:join-line' }
{ label: '&Join Lines', command: 'editor:join-lines' }
]
}
{

View File

@ -2635,18 +2635,18 @@ describe "Editor", ->
editor.destroy()
expect(buffer.getMarkerCount()).toBe 0
describe ".joinLine()", ->
describe ".joinLines()", ->
describe "when no text is selected", ->
describe "when the line below isn't empty", ->
it "joins the line below with the current line separated by a space and moves the cursor to the start of line that was moved up", ->
editor.joinLine()
editor.joinLines()
expect(editor.lineForBufferRow(0)).toBe 'var quicksort = function () { var sort = function(items) {'
expect(editor.getCursorBufferPosition()).toEqual [0, 30]
describe "when the line below is empty", ->
it "deletes the line below and moves the cursor to the end of the line", ->
editor.setCursorBufferPosition([9])
editor.joinLine()
editor.joinLines()
expect(editor.lineForBufferRow(9)).toBe ' };'
expect(editor.lineForBufferRow(10)).toBe ' return sort(Array.apply(this, arguments));'
expect(editor.getCursorBufferPosition()).toEqual [9, 4]
@ -2654,21 +2654,21 @@ describe "Editor", ->
describe "when the cursor is on the last row", ->
it "does nothing", ->
editor.setCursorBufferPosition([Infinity, Infinity])
editor.joinLine()
editor.joinLines()
expect(editor.lineForBufferRow(12)).toBe '};'
describe "when text is selected", ->
describe "when the selection does not span multiple lines", ->
it "joins the line below with the current line separated by a space and retains the selected text", ->
editor.setSelectedBufferRange([[0, 1], [0, 3]])
editor.joinLine()
editor.joinLines()
expect(editor.lineForBufferRow(0)).toBe 'var quicksort = function () { var sort = function(items) {'
expect(editor.getSelectedBufferRange()).toEqual [[0, 1], [0, 3]]
describe "when the selection spans multiple lines", ->
it "joins all selected lines separated by a space and retains the selected text", ->
editor.setSelectedBufferRange([[9, 3], [12, 1]])
editor.joinLine()
editor.joinLines()
expect(editor.lineForBufferRow(9)).toBe ' }; return sort(Array.apply(this, arguments)); };'
expect(editor.getSelectedBufferRange()).toEqual [[9, 3], [9, 49]]

View File

@ -210,7 +210,7 @@ class EditorView extends View
'editor:move-line-up': => @editor.moveLineUp()
'editor:move-line-down': => @editor.moveLineDown()
'editor:duplicate-line': => @editor.duplicateLine()
'editor:join-line': => @editor.joinLine()
'editor:join-lines': => @editor.joinLines()
'editor:toggle-indent-guide': => atom.config.toggle('editor.showIndentGuide')
'editor:toggle-line-numbers': => atom.config.toggle('editor.showLineNumbers')
'editor:scroll-to-cursor': => @scrollToCursorPosition()

View File

@ -1593,10 +1593,8 @@ class Editor extends Model
#
# Joining a line means that multiple lines are converted to a single line with
# the contents of each of the original non-empty lines separated by a space.
#
# TODO: Rename to joinLines?
joinLine: ->
@mutateSelectedText (selection) -> selection.joinLine()
joinLines: ->
@mutateSelectedText (selection) -> selection.joinLines()
# Public: Expand selections to the beginning of their containing word.
#

View File

@ -437,7 +437,7 @@ class Selection
# Public: Joins the current line with the one below it.
#
# If there selection spans more than one line, all the lines are joined together.
joinLine: ->
joinLines: ->
selectedRange = @getBufferRange()
if selectedRange.isEmpty()
return if selectedRange.start.row is @editor.buffer.getLastRow()