Rename duplicate-line to duplicate-lines (but retain deprecated method)

Might as well make the name accurate while it's early.
This commit is contained in:
Nathan Sobo 2014-03-06 13:20:20 -07:00
parent 76200884d5
commit 20a0c27111
8 changed files with 18 additions and 14 deletions

View File

@ -134,7 +134,7 @@
'ctrl-cmd-down': 'editor:move-line-down'
'cmd-/': 'editor:toggle-line-comments'
'cmd-j': 'editor:join-lines'
'cmd-D': 'editor:duplicate-line'
'cmd-D': 'editor:duplicate-lines'
'cmd-L': 'editor:split-selections-into-lines'
'cmd-alt-[': 'editor:fold-current-row'

View File

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

View File

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

View File

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

View File

@ -2675,7 +2675,7 @@ describe "Editor", ->
editor.setCursorBufferPosition([2, 5])
editor.addSelectionForBufferRange([[3, 0], [8, 0]], preserveFolds: true)
editor.duplicateLine()
editor.duplicateLines()
expect(editor.getTextInBufferRange([[2, 0], [13, 5]])).toBe """
\ if (items.length <= 1) return items;
@ -2703,7 +2703,7 @@ describe "Editor", ->
editor.foldBufferRow(4)
editor.setCursorBufferPosition([4, 0])
editor.duplicateLine()
editor.duplicateLines()
expect(editor.getTextInBufferRange([[2, 0], [11, 5]])).toBe """
\ if (items.length <= 1) return items;

View File

@ -2781,12 +2781,12 @@ describe "EditorView", ->
expect(buffer.lineForRow(1)).toBe ' if (items.length <= 1) return items;'
expect(buffer.lineForRow(2)).toBe ' var sort = function(items) {'
describe "when editor:duplicate-line is triggered", ->
describe "when editor:duplicate-lines is triggered", ->
describe "where there is no selection", ->
describe "when the cursor isn't on a folded line", ->
it "duplicates the current line below and moves the cursor down one row", ->
editor.setCursorBufferPosition([0, 5])
editorView.trigger 'editor:duplicate-line'
editorView.trigger 'editor:duplicate-lines'
expect(buffer.lineForRow(0)).toBe 'var quicksort = function () {'
expect(buffer.lineForRow(1)).toBe 'var quicksort = function () {'
expect(editor.getCursorBufferPosition()).toEqual [1, 5]
@ -2795,7 +2795,7 @@ describe "EditorView", ->
it "duplicates the entire fold before and moves the cursor to the new fold", ->
editor.setCursorBufferPosition([4])
editor.foldCurrentRow()
editorView.trigger 'editor:duplicate-line'
editorView.trigger 'editor:duplicate-lines'
expect(editor.getCursorScreenPosition()).toEqual [5]
expect(editor.isFoldedAtScreenRow(4)).toBeTruthy()
expect(editor.isFoldedAtScreenRow(5)).toBeTruthy()
@ -2807,7 +2807,7 @@ describe "EditorView", ->
describe "when the cursor is on the last line and it doesn't have a trailing newline", ->
it "inserts a newline and the duplicated line", ->
editor.moveCursorToBottom()
editorView.trigger 'editor:duplicate-line'
editorView.trigger 'editor:duplicate-lines'
expect(buffer.lineForRow(12)).toBe '};'
expect(buffer.lineForRow(13)).toBe '};'
expect(buffer.lineForRow(14)).toBeUndefined()
@ -2818,7 +2818,7 @@ describe "EditorView", ->
editor.moveCursorToBottom()
editor.insertNewline()
editor.moveCursorToBottom()
editorView.trigger 'editor:duplicate-line'
editorView.trigger 'editor:duplicate-lines'
expect(buffer.lineForRow(13)).toBe ''
expect(buffer.lineForRow(14)).toBe ''
expect(buffer.lineForRow(15)).toBeUndefined()
@ -2829,7 +2829,7 @@ describe "EditorView", ->
editor.moveCursorToBottom()
editor.insertNewline()
editor.setCursorBufferPosition([12])
editorView.trigger 'editor:duplicate-line'
editorView.trigger 'editor:duplicate-lines'
expect(buffer.lineForRow(12)).toBe '};'
expect(buffer.lineForRow(13)).toBe '};'
expect(buffer.lineForRow(14)).toBe ''

View File

@ -209,7 +209,7 @@ class EditorView extends View
'editor:copy-path': => @copyPathToClipboard()
'editor:move-line-up': => @editor.moveLineUp()
'editor:move-line-down': => @editor.moveLineDown()
'editor:duplicate-line': => @editor.duplicateLine()
'editor:duplicate-lines': => @editor.duplicateLines()
'editor:join-lines': => @editor.joinLines()
'editor:toggle-indent-guide': => atom.config.toggle('editor.showIndentGuide')
'editor:toggle-line-numbers': => atom.config.toggle('editor.showLineNumbers')

View File

@ -952,7 +952,7 @@ class Editor extends Model
@setSelectedBufferRange(selection.translate([insertDelta]), preserveFolds: true)
# Duplicate the most recent cursor's current line.
duplicateLine: ->
duplicateLines: ->
@transact =>
for selection in @getSelectionsOrderedByBufferPosition().reverse()
selectedBufferRange = selection.getBufferRange()
@ -976,6 +976,10 @@ class Editor extends Model
for [foldStartRow, foldEndRow] in foldedRowRanges
@createFold(foldStartRow + delta, foldEndRow + delta)
# Deprecated: Use {::duplicateLines} instead.
duplicateLine: ->
@duplicateLines()
mutateSelectedText: (fn) ->
@transact => fn(selection) for selection in @getSelections()