diff --git a/keymaps/darwin.cson b/keymaps/darwin.cson index 750a1468f..728fe430b 100644 --- a/keymaps/darwin.cson +++ b/keymaps/darwin.cson @@ -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' diff --git a/keymaps/win32.cson b/keymaps/win32.cson index ca306414e..84bd3a1f5 100644 --- a/keymaps/win32.cson +++ b/keymaps/win32.cson @@ -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' diff --git a/menus/darwin.cson b/menus/darwin.cson index 5785321d8..f72552fac 100644 --- a/menus/darwin.cson +++ b/menus/darwin.cson @@ -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' } ] } { diff --git a/menus/win32.cson b/menus/win32.cson index 320c1841a..e22f3bfcc 100644 --- a/menus/win32.cson +++ b/menus/win32.cson @@ -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' } ] } { diff --git a/spec/editor-spec.coffee b/spec/editor-spec.coffee index 4de1a2e25..d8ec6cbf1 100644 --- a/spec/editor-spec.coffee +++ b/spec/editor-spec.coffee @@ -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]] diff --git a/src/editor-view.coffee b/src/editor-view.coffee index 8c1a5aa22..adb19498e 100644 --- a/src/editor-view.coffee +++ b/src/editor-view.coffee @@ -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() diff --git a/src/editor.coffee b/src/editor.coffee index 4e0b53983..3dc934254 100644 --- a/src/editor.coffee +++ b/src/editor.coffee @@ -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. # diff --git a/src/selection.coffee b/src/selection.coffee index 612531218..58492d6f3 100644 --- a/src/selection.coffee +++ b/src/selection.coffee @@ -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()