Merge pull request #3116 from maschs/ms-srcLint

coffeelint!
This commit is contained in:
Kevin Sawicki
2014-08-15 13:52:15 -07:00
13 changed files with 151 additions and 151 deletions

View File

@@ -101,7 +101,7 @@ $.fn.resultOfTrigger = (type) ->
event.result event.result
$.fn.enableKeymap = -> $.fn.enableKeymap = ->
@on 'keydown', (e) => window.keymap.handleKeyEvent(e) @on 'keydown', (e) -> window.keymap.handleKeyEvent(e)
$.fn.attachToDom = -> $.fn.attachToDom = ->
$('#jasmine-content').append(this) $('#jasmine-content').append(this)

View File

@@ -119,14 +119,14 @@ class AtomReporter extends View
grim.clearDeprecations() grim.clearDeprecations()
handleEvents: -> handleEvents: ->
$(document).on "click", ".spec-toggle", ({currentTarget}) => $(document).on "click", ".spec-toggle", ({currentTarget}) ->
element = $(currentTarget) element = $(currentTarget)
specFailures = element.parent().find('.spec-failures') specFailures = element.parent().find('.spec-failures')
specFailures.toggle() specFailures.toggle()
element.toggleClass('folded') element.toggleClass('folded')
false false
$(document).on "click", ".deprecation-toggle", ({currentTarget}) => $(document).on "click", ".deprecation-toggle", ({currentTarget}) ->
element = $(currentTarget) element = $(currentTarget)
deprecationList = $(document).find('.deprecation-list') deprecationList = $(document).find('.deprecation-list')
deprecationList.toggle() deprecationList.toggle()

View File

@@ -18,7 +18,7 @@ class TimeReporter extends jasmine.Reporter
log ?= (line) -> console.log(line) log ?= (line) -> console.log(line)
log "Longest running suites:" log "Longest running suites:"
suites = _.map(window.timedSuites, (key, value) -> [value, key]) suites = _.map(window.timedSuites, (key, value) -> [value, key])
for suite in _.sortBy(suites, (suite) => -suite[1])[0...number] for suite in _.sortBy(suites, (suite) -> -suite[1])[0...number]
time = Math.round(suite[1] / 100) / 10 time = Math.round(suite[1] / 100) / 10
log " #{suite[0]} (#{time}s)" log " #{suite[0]} (#{time}s)"
undefined undefined

View File

@@ -41,7 +41,7 @@ module.exports =
callback() callback()
return return
symlinkCommand commandPath, destinationPath, (error) => symlinkCommand commandPath, destinationPath, (error) ->
if askForPrivilege and error?.code is 'EACCES' if askForPrivilege and error?.code is 'EACCES'
try try
error = null error = null

View File

@@ -39,7 +39,7 @@ class Config
fs.makeTreeSync(@configDirPath) fs.makeTreeSync(@configDirPath)
queue = async.queue ({sourcePath, destinationPath}, callback) => queue = async.queue ({sourcePath, destinationPath}, callback) ->
fs.copy(sourcePath, destinationPath, callback) fs.copy(sourcePath, destinationPath, callback)
queue.drain = done queue.drain = done

View File

@@ -120,7 +120,7 @@ class Cursor extends Model
# (default: true) # (default: true)
# #
# Returns a {RegExp}. # Returns a {RegExp}.
wordRegExp: ({includeNonWordCharacters}={})-> wordRegExp: ({includeNonWordCharacters}={}) ->
includeNonWordCharacters ?= true includeNonWordCharacters ?= true
nonWordCharacters = atom.config.get('editor.nonWordCharacters') nonWordCharacters = atom.config.get('editor.nonWordCharacters')
segments = ["^[\t ]*$"] segments = ["^[\t ]*$"]
@@ -286,7 +286,7 @@ class Cursor extends Model
position = @getBufferPosition() position = @getBufferPosition()
scanRange = @getCurrentLineBufferRange() scanRange = @getCurrentLineBufferRange()
endOfLeadingWhitespace = null endOfLeadingWhitespace = null
@editor.scanInBufferRange /^[ \t]*/, scanRange, ({range}) => @editor.scanInBufferRange /^[ \t]*/, scanRange, ({range}) ->
endOfLeadingWhitespace = range.end endOfLeadingWhitespace = range.end
@setBufferPosition(endOfLeadingWhitespace) if endOfLeadingWhitespace.isGreaterThan(position) @setBufferPosition(endOfLeadingWhitespace) if endOfLeadingWhitespace.isGreaterThan(position)
@@ -342,7 +342,7 @@ class Cursor extends Model
scanRange = [[previousNonBlankRow, 0], currentBufferPosition] scanRange = [[previousNonBlankRow, 0], currentBufferPosition]
beginningOfWordPosition = null beginningOfWordPosition = null
@editor.backwardsScanInBufferRange (options.wordRegex ? @wordRegExp(options)), scanRange, ({range, stop}) => @editor.backwardsScanInBufferRange (options.wordRegex ? @wordRegExp(options)), scanRange, ({range, stop}) ->
if range.end.isGreaterThanOrEqual(currentBufferPosition) or allowPrevious if range.end.isGreaterThanOrEqual(currentBufferPosition) or allowPrevious
beginningOfWordPosition = range.start beginningOfWordPosition = range.start
if not beginningOfWordPosition?.isEqual(currentBufferPosition) if not beginningOfWordPosition?.isEqual(currentBufferPosition)
@@ -363,7 +363,7 @@ class Cursor extends Model
scanRange = [[previousNonBlankRow, 0], currentBufferPosition] scanRange = [[previousNonBlankRow, 0], currentBufferPosition]
beginningOfWordPosition = null beginningOfWordPosition = null
@editor.backwardsScanInBufferRange (options.wordRegex ? @wordRegExp()), scanRange, ({range, stop}) => @editor.backwardsScanInBufferRange (options.wordRegex ? @wordRegExp()), scanRange, ({range, stop}) ->
if range.start.row < currentBufferPosition.row and currentBufferPosition.column > 0 if range.start.row < currentBufferPosition.row and currentBufferPosition.column > 0
# force it to stop at the beginning of each line # force it to stop at the beginning of each line
beginningOfWordPosition = new Point(currentBufferPosition.row, 0) beginningOfWordPosition = new Point(currentBufferPosition.row, 0)
@@ -384,7 +384,7 @@ class Cursor extends Model
scanRange = [currentBufferPosition, @editor.getEofBufferPosition()] scanRange = [currentBufferPosition, @editor.getEofBufferPosition()]
endOfWordPosition = null endOfWordPosition = null
@editor.scanInBufferRange (options.wordRegex ? @wordRegExp()), scanRange, ({range, stop}) => @editor.scanInBufferRange (options.wordRegex ? @wordRegExp()), scanRange, ({range, stop}) ->
if range.start.row > currentBufferPosition.row if range.start.row > currentBufferPosition.row
# force it to stop at the beginning of each line # force it to stop at the beginning of each line
endOfWordPosition = new Point(range.start.row, 0) endOfWordPosition = new Point(range.start.row, 0)
@@ -414,7 +414,7 @@ class Cursor extends Model
scanRange = [currentBufferPosition, @editor.getEofBufferPosition()] scanRange = [currentBufferPosition, @editor.getEofBufferPosition()]
endOfWordPosition = null endOfWordPosition = null
@editor.scanInBufferRange (options.wordRegex ? @wordRegExp(options)), scanRange, ({range, stop}) => @editor.scanInBufferRange (options.wordRegex ? @wordRegExp(options)), scanRange, ({range, stop}) ->
if range.start.isLessThanOrEqual(currentBufferPosition) or allowNext if range.start.isLessThanOrEqual(currentBufferPosition) or allowNext
endOfWordPosition = range.end endOfWordPosition = range.end
if not endOfWordPosition?.isEqual(currentBufferPosition) if not endOfWordPosition?.isEqual(currentBufferPosition)
@@ -435,7 +435,7 @@ class Cursor extends Model
scanRange = [start, @editor.getEofBufferPosition()] scanRange = [start, @editor.getEofBufferPosition()]
beginningOfNextWordPosition = null beginningOfNextWordPosition = null
@editor.scanInBufferRange (options.wordRegex ? @wordRegExp()), scanRange, ({range, stop}) => @editor.scanInBufferRange (options.wordRegex ? @wordRegExp()), scanRange, ({range, stop}) ->
beginningOfNextWordPosition = range.start beginningOfNextWordPosition = range.start
stop() stop()
@@ -477,7 +477,7 @@ class Cursor extends Model
{row, column} = eof {row, column} = eof
position = new Point(row, column - 1) position = new Point(row, column - 1)
@editor.scanInBufferRange /^\n*$/g, scanRange, ({range, stop}) => @editor.scanInBufferRange /^\n*$/g, scanRange, ({range, stop}) ->
if !range.start.isEqual(start) if !range.start.isEqual(start)
position = range.start position = range.start
stop() stop()
@@ -490,7 +490,7 @@ class Cursor extends Model
scanRange = [[row-1, column], [0,0]] scanRange = [[row-1, column], [0,0]]
position = new Point(0, 0) position = new Point(0, 0)
zero = new Point(0,0) zero = new Point(0,0)
@editor.backwardsScanInBufferRange /^\n*$/g, scanRange, ({range, stop}) => @editor.backwardsScanInBufferRange /^\n*$/g, scanRange, ({range, stop}) ->
if !range.start.isEqual(zero) if !range.start.isEqual(zero)
position = range.start position = range.start
stop() stop()

View File

@@ -981,7 +981,7 @@ class DisplayBuffer extends Model
@tokenizedBuffer.destroy() @tokenizedBuffer.destroy()
@unsubscribe() @unsubscribe()
logLines: (start=0, end=@getLastRow())-> logLines: (start=0, end=@getLastRow()) ->
for row in [start..end] for row in [start..end]
line = @lineForRow(row).text line = @lineForRow(row).text
console.log row, @bufferRowForScreenRow(row), line, line.length console.log row, @bufferRowForScreenRow(row), line, line.length

View File

@@ -410,105 +410,105 @@ EditorComponent = React.createClass
{parentView, editor, mini} = @props {parentView, editor, mini} = @props
@addCommandListeners @addCommandListeners
'core:move-left': => editor.moveCursorLeft() 'core:move-left': -> editor.moveCursorLeft()
'core:move-right': => editor.moveCursorRight() 'core:move-right': -> editor.moveCursorRight()
'core:select-left': => editor.selectLeft() 'core:select-left': -> editor.selectLeft()
'core:select-right': => editor.selectRight() 'core:select-right': -> editor.selectRight()
'core:select-all': => editor.selectAll() 'core:select-all': -> editor.selectAll()
'core:backspace': => editor.backspace() 'core:backspace': -> editor.backspace()
'core:delete': => editor.delete() 'core:delete': -> editor.delete()
'core:undo': => editor.undo() 'core:undo': -> editor.undo()
'core:redo': => editor.redo() 'core:redo': -> editor.redo()
'core:cut': => editor.cutSelectedText() 'core:cut': -> editor.cutSelectedText()
'core:copy': => editor.copySelectedText() 'core:copy': -> editor.copySelectedText()
'core:paste': => editor.pasteText() 'core:paste': -> editor.pasteText()
'editor:move-to-previous-word': => editor.moveCursorToPreviousWord() 'editor:move-to-previous-word': -> editor.moveCursorToPreviousWord()
'editor:select-word': => editor.selectWord() 'editor:select-word': -> editor.selectWord()
'editor:consolidate-selections': @consolidateSelections 'editor:consolidate-selections': @consolidateSelections
'editor:delete-to-beginning-of-word': => editor.deleteToBeginningOfWord() 'editor:delete-to-beginning-of-word': -> editor.deleteToBeginningOfWord()
'editor:delete-to-beginning-of-line': => editor.deleteToBeginningOfLine() 'editor:delete-to-beginning-of-line': -> editor.deleteToBeginningOfLine()
'editor:delete-to-end-of-line': => editor.deleteToEndOfLine() 'editor:delete-to-end-of-line': -> editor.deleteToEndOfLine()
'editor:delete-to-end-of-word': => editor.deleteToEndOfWord() 'editor:delete-to-end-of-word': -> editor.deleteToEndOfWord()
'editor:delete-line': => editor.deleteLine() 'editor:delete-line': -> editor.deleteLine()
'editor:cut-to-end-of-line': => editor.cutToEndOfLine() 'editor:cut-to-end-of-line': -> editor.cutToEndOfLine()
'editor:move-to-beginning-of-next-paragraph': => editor.moveCursorToBeginningOfNextParagraph() 'editor:move-to-beginning-of-next-paragraph': -> editor.moveCursorToBeginningOfNextParagraph()
'editor:move-to-beginning-of-previous-paragraph': => editor.moveCursorToBeginningOfPreviousParagraph() 'editor:move-to-beginning-of-previous-paragraph': -> editor.moveCursorToBeginningOfPreviousParagraph()
'editor:move-to-beginning-of-screen-line': => editor.moveCursorToBeginningOfScreenLine() 'editor:move-to-beginning-of-screen-line': -> editor.moveCursorToBeginningOfScreenLine()
'editor:move-to-beginning-of-line': => editor.moveCursorToBeginningOfLine() 'editor:move-to-beginning-of-line': -> editor.moveCursorToBeginningOfLine()
'editor:move-to-end-of-screen-line': => editor.moveCursorToEndOfScreenLine() 'editor:move-to-end-of-screen-line': -> editor.moveCursorToEndOfScreenLine()
'editor:move-to-end-of-line': => editor.moveCursorToEndOfLine() 'editor:move-to-end-of-line': -> editor.moveCursorToEndOfLine()
'editor:move-to-first-character-of-line': => editor.moveCursorToFirstCharacterOfLine() 'editor:move-to-first-character-of-line': -> editor.moveCursorToFirstCharacterOfLine()
'editor:move-to-beginning-of-word': => editor.moveCursorToBeginningOfWord() 'editor:move-to-beginning-of-word': -> editor.moveCursorToBeginningOfWord()
'editor:move-to-end-of-word': => editor.moveCursorToEndOfWord() 'editor:move-to-end-of-word': -> editor.moveCursorToEndOfWord()
'editor:move-to-beginning-of-next-word': => editor.moveCursorToBeginningOfNextWord() 'editor:move-to-beginning-of-next-word': -> editor.moveCursorToBeginningOfNextWord()
'editor:move-to-previous-word-boundary': => editor.moveCursorToPreviousWordBoundary() 'editor:move-to-previous-word-boundary': -> editor.moveCursorToPreviousWordBoundary()
'editor:move-to-next-word-boundary': => editor.moveCursorToNextWordBoundary() 'editor:move-to-next-word-boundary': -> editor.moveCursorToNextWordBoundary()
'editor:select-to-beginning-of-next-paragraph': => editor.selectToBeginningOfNextParagraph() 'editor:select-to-beginning-of-next-paragraph': -> editor.selectToBeginningOfNextParagraph()
'editor:select-to-beginning-of-previous-paragraph': => editor.selectToBeginningOfPreviousParagraph() 'editor:select-to-beginning-of-previous-paragraph': -> editor.selectToBeginningOfPreviousParagraph()
'editor:select-to-end-of-line': => editor.selectToEndOfLine() 'editor:select-to-end-of-line': -> editor.selectToEndOfLine()
'editor:select-to-beginning-of-line': => editor.selectToBeginningOfLine() 'editor:select-to-beginning-of-line': -> editor.selectToBeginningOfLine()
'editor:select-to-end-of-word': => editor.selectToEndOfWord() 'editor:select-to-end-of-word': -> editor.selectToEndOfWord()
'editor:select-to-beginning-of-word': => editor.selectToBeginningOfWord() 'editor:select-to-beginning-of-word': -> editor.selectToBeginningOfWord()
'editor:select-to-beginning-of-next-word': => editor.selectToBeginningOfNextWord() 'editor:select-to-beginning-of-next-word': -> editor.selectToBeginningOfNextWord()
'editor:select-to-next-word-boundary': => editor.selectToNextWordBoundary() 'editor:select-to-next-word-boundary': -> editor.selectToNextWordBoundary()
'editor:select-to-previous-word-boundary': => editor.selectToPreviousWordBoundary() 'editor:select-to-previous-word-boundary': -> editor.selectToPreviousWordBoundary()
'editor:select-to-first-character-of-line': => editor.selectToFirstCharacterOfLine() 'editor:select-to-first-character-of-line': -> editor.selectToFirstCharacterOfLine()
'editor:select-line': => editor.selectLine() 'editor:select-line': -> editor.selectLine()
'editor:transpose': => editor.transpose() 'editor:transpose': -> editor.transpose()
'editor:upper-case': => editor.upperCase() 'editor:upper-case': -> editor.upperCase()
'editor:lower-case': => editor.lowerCase() 'editor:lower-case': -> editor.lowerCase()
unless mini unless mini
@addCommandListeners @addCommandListeners
'core:move-up': => editor.moveCursorUp() 'core:move-up': -> editor.moveCursorUp()
'core:move-down': => editor.moveCursorDown() 'core:move-down': -> editor.moveCursorDown()
'core:move-to-top': => editor.moveCursorToTop() 'core:move-to-top': -> editor.moveCursorToTop()
'core:move-to-bottom': => editor.moveCursorToBottom() 'core:move-to-bottom': -> editor.moveCursorToBottom()
'core:page-up': => editor.pageUp() 'core:page-up': -> editor.pageUp()
'core:page-down': => editor.pageDown() 'core:page-down': -> editor.pageDown()
'core:select-up': => editor.selectUp() 'core:select-up': -> editor.selectUp()
'core:select-down': => editor.selectDown() 'core:select-down': -> editor.selectDown()
'core:select-to-top': => editor.selectToTop() 'core:select-to-top': -> editor.selectToTop()
'core:select-to-bottom': => editor.selectToBottom() 'core:select-to-bottom': -> editor.selectToBottom()
'core:select-page-up': => editor.selectPageUp() 'core:select-page-up': -> editor.selectPageUp()
'core:select-page-down': => editor.selectPageDown() 'core:select-page-down': -> editor.selectPageDown()
'editor:indent': => editor.indent() 'editor:indent': -> editor.indent()
'editor:auto-indent': => editor.autoIndentSelectedRows() 'editor:auto-indent': -> editor.autoIndentSelectedRows()
'editor:indent-selected-rows': => editor.indentSelectedRows() 'editor:indent-selected-rows': -> editor.indentSelectedRows()
'editor:outdent-selected-rows': => editor.outdentSelectedRows() 'editor:outdent-selected-rows': -> editor.outdentSelectedRows()
'editor:newline': => editor.insertNewline() 'editor:newline': -> editor.insertNewline()
'editor:newline-below': => editor.insertNewlineBelow() 'editor:newline-below': -> editor.insertNewlineBelow()
'editor:newline-above': => editor.insertNewlineAbove() 'editor:newline-above': -> editor.insertNewlineAbove()
'editor:add-selection-below': => editor.addSelectionBelow() 'editor:add-selection-below': -> editor.addSelectionBelow()
'editor:add-selection-above': => editor.addSelectionAbove() 'editor:add-selection-above': -> editor.addSelectionAbove()
'editor:split-selections-into-lines': => editor.splitSelectionsIntoLines() 'editor:split-selections-into-lines': -> editor.splitSelectionsIntoLines()
'editor:toggle-soft-tabs': => editor.toggleSoftTabs() 'editor:toggle-soft-tabs': -> editor.toggleSoftTabs()
'editor:toggle-soft-wrap': => editor.toggleSoftWrap() 'editor:toggle-soft-wrap': -> editor.toggleSoftWrap()
'editor:fold-all': => editor.foldAll() 'editor:fold-all': -> editor.foldAll()
'editor:unfold-all': => editor.unfoldAll() 'editor:unfold-all': -> editor.unfoldAll()
'editor:fold-current-row': => editor.foldCurrentRow() 'editor:fold-current-row': -> editor.foldCurrentRow()
'editor:unfold-current-row': => editor.unfoldCurrentRow() 'editor:unfold-current-row': -> editor.unfoldCurrentRow()
'editor:fold-selection': => editor.foldSelectedLines() 'editor:fold-selection': -> editor.foldSelectedLines()
'editor:fold-at-indent-level-1': => editor.foldAllAtIndentLevel(0) 'editor:fold-at-indent-level-1': -> editor.foldAllAtIndentLevel(0)
'editor:fold-at-indent-level-2': => editor.foldAllAtIndentLevel(1) 'editor:fold-at-indent-level-2': -> editor.foldAllAtIndentLevel(1)
'editor:fold-at-indent-level-3': => editor.foldAllAtIndentLevel(2) 'editor:fold-at-indent-level-3': -> editor.foldAllAtIndentLevel(2)
'editor:fold-at-indent-level-4': => editor.foldAllAtIndentLevel(3) 'editor:fold-at-indent-level-4': -> editor.foldAllAtIndentLevel(3)
'editor:fold-at-indent-level-5': => editor.foldAllAtIndentLevel(4) 'editor:fold-at-indent-level-5': -> editor.foldAllAtIndentLevel(4)
'editor:fold-at-indent-level-6': => editor.foldAllAtIndentLevel(5) 'editor:fold-at-indent-level-6': -> editor.foldAllAtIndentLevel(5)
'editor:fold-at-indent-level-7': => editor.foldAllAtIndentLevel(6) 'editor:fold-at-indent-level-7': -> editor.foldAllAtIndentLevel(6)
'editor:fold-at-indent-level-8': => editor.foldAllAtIndentLevel(7) 'editor:fold-at-indent-level-8': -> editor.foldAllAtIndentLevel(7)
'editor:fold-at-indent-level-9': => editor.foldAllAtIndentLevel(8) 'editor:fold-at-indent-level-9': -> editor.foldAllAtIndentLevel(8)
'editor:toggle-line-comments': => editor.toggleLineCommentsInSelection() 'editor:toggle-line-comments': -> editor.toggleLineCommentsInSelection()
'editor:log-cursor-scope': => editor.logCursorScope() 'editor:log-cursor-scope': -> editor.logCursorScope()
'editor:checkout-head-revision': => atom.project.getRepo()?.checkoutHeadForEditor(editor) 'editor:checkout-head-revision': -> editor.checkoutHead()
'editor:copy-path': => editor.copyPathToClipboard() 'editor:copy-path': -> editor.copyPathToClipboard()
'editor:move-line-up': => editor.moveLineUp() 'editor:move-line-up': -> editor.moveLineUp()
'editor:move-line-down': => editor.moveLineDown() 'editor:move-line-down': -> editor.moveLineDown()
'editor:duplicate-lines': => editor.duplicateLines() 'editor:duplicate-lines': -> editor.duplicateLines()
'editor:join-lines': => editor.joinLines() 'editor:join-lines': -> editor.joinLines()
'editor:toggle-indent-guide': => atom.config.toggle('editor.showIndentGuide') 'editor:toggle-indent-guide': -> atom.config.toggle('editor.showIndentGuide')
'editor:toggle-line-numbers': => atom.config.toggle('editor.showLineNumbers') 'editor:toggle-line-numbers': -> atom.config.toggle('editor.showLineNumbers')
'editor:scroll-to-cursor': => editor.scrollToCursorPosition() 'editor:scroll-to-cursor': -> editor.scrollToCursorPosition()
'benchmark:scroll': @runScrollBenchmark 'benchmark:scroll': @runScrollBenchmark
addCommandListeners: (listenersByCommandName) -> addCommandListeners: (listenersByCommandName) ->

View File

@@ -243,8 +243,8 @@ class EditorView extends View
'editor:move-line-down': => @editor.moveLineDown() 'editor:move-line-down': => @editor.moveLineDown()
'editor:duplicate-lines': => @editor.duplicateLines() 'editor:duplicate-lines': => @editor.duplicateLines()
'editor:join-lines': => @editor.joinLines() 'editor:join-lines': => @editor.joinLines()
'editor:toggle-indent-guide': => atom.config.toggle('editor.showIndentGuide') 'editor:toggle-indent-guide': -> atom.config.toggle('editor.showIndentGuide')
'editor:toggle-line-numbers': => atom.config.toggle('editor.showLineNumbers') 'editor:toggle-line-numbers': -> atom.config.toggle('editor.showLineNumbers')
'editor:scroll-to-cursor': => @scrollToCursorPosition() 'editor:scroll-to-cursor': => @scrollToCursorPosition()
documentation = {} documentation = {}
@@ -270,7 +270,7 @@ class EditorView extends View
insertText: (text, options) -> insertText: (text, options) ->
@editor.insertText(text, options) @editor.insertText(text, options)
setHeightInLines: (heightInLines)-> setHeightInLines: (heightInLines) ->
heightInLines ?= @calculateHeightInLines() heightInLines ?= @calculateHeightInLines()
@heightInLines = heightInLines if heightInLines @heightInLines = heightInLines if heightInLines

View File

@@ -691,7 +691,7 @@ class Editor extends Model
# Indent all lines intersecting selections. See {Selection::indent} for more # Indent all lines intersecting selections. See {Selection::indent} for more
# information. # information.
indent: (options={})-> indent: (options={}) ->
options.autoIndent ?= @shouldAutoIndent() options.autoIndent ?= @shouldAutoIndent()
@mutateSelectedText (selection) -> selection.indent(options) @mutateSelectedText (selection) -> selection.indent(options)
@@ -1669,55 +1669,55 @@ class Editor extends Model
# #
# This method may merge selections that end up intesecting. # This method may merge selections that end up intesecting.
selectRight: -> selectRight: ->
@expandSelectionsForward (selection) => selection.selectRight() @expandSelectionsForward (selection) -> selection.selectRight()
# Public: Move the cursor of each selection one character leftward while # Public: Move the cursor of each selection one character leftward while
# preserving the selection's tail position. # preserving the selection's tail position.
# #
# This method may merge selections that end up intesecting. # This method may merge selections that end up intesecting.
selectLeft: -> selectLeft: ->
@expandSelectionsBackward (selection) => selection.selectLeft() @expandSelectionsBackward (selection) -> selection.selectLeft()
# Public: Move the cursor of each selection one character upward while # Public: Move the cursor of each selection one character upward while
# preserving the selection's tail position. # preserving the selection's tail position.
# #
# This method may merge selections that end up intesecting. # This method may merge selections that end up intesecting.
selectUp: (rowCount) -> selectUp: (rowCount) ->
@expandSelectionsBackward (selection) => selection.selectUp(rowCount) @expandSelectionsBackward (selection) -> selection.selectUp(rowCount)
# Public: Move the cursor of each selection one character downward while # Public: Move the cursor of each selection one character downward while
# preserving the selection's tail position. # preserving the selection's tail position.
# #
# This method may merge selections that end up intesecting. # This method may merge selections that end up intesecting.
selectDown: (rowCount) -> selectDown: (rowCount) ->
@expandSelectionsForward (selection) => selection.selectDown(rowCount) @expandSelectionsForward (selection) -> selection.selectDown(rowCount)
# Public: Select from the top of the buffer to the end of the last selection # Public: Select from the top of the buffer to the end of the last selection
# in the buffer. # in the buffer.
# #
# This method merges multiple selections into a single selection. # This method merges multiple selections into a single selection.
selectToTop: -> selectToTop: ->
@expandSelectionsBackward (selection) => selection.selectToTop() @expandSelectionsBackward (selection) -> selection.selectToTop()
# Public: Select all text in the buffer. # Public: Select all text in the buffer.
# #
# This method merges multiple selections into a single selection. # This method merges multiple selections into a single selection.
selectAll: -> selectAll: ->
@expandSelectionsForward (selection) => selection.selectAll() @expandSelectionsForward (selection) -> selection.selectAll()
# Public: Selects from the top of the first selection in the buffer to the end # Public: Selects from the top of the first selection in the buffer to the end
# of the buffer. # of the buffer.
# #
# This method merges multiple selections into a single selection. # This method merges multiple selections into a single selection.
selectToBottom: -> selectToBottom: ->
@expandSelectionsForward (selection) => selection.selectToBottom() @expandSelectionsForward (selection) -> selection.selectToBottom()
# Public: Move the cursor of each selection to the beginning of its line # Public: Move the cursor of each selection to the beginning of its line
# while preserving the selection's tail position. # while preserving the selection's tail position.
# #
# This method may merge selections that end up intesecting. # This method may merge selections that end up intesecting.
selectToBeginningOfLine: -> selectToBeginningOfLine: ->
@expandSelectionsBackward (selection) => selection.selectToBeginningOfLine() @expandSelectionsBackward (selection) -> selection.selectToBeginningOfLine()
# Public: Move the cursor of each selection to the first non-whitespace # Public: Move the cursor of each selection to the first non-whitespace
# character of its line while preserving the selection's tail position. If the # character of its line while preserving the selection's tail position. If the
@@ -1726,34 +1726,34 @@ class Editor extends Model
# #
# This method may merge selections that end up intersecting. # This method may merge selections that end up intersecting.
selectToFirstCharacterOfLine: -> selectToFirstCharacterOfLine: ->
@expandSelectionsBackward (selection) => selection.selectToFirstCharacterOfLine() @expandSelectionsBackward (selection) -> selection.selectToFirstCharacterOfLine()
# Public: Move the cursor of each selection to the end of its line while # Public: Move the cursor of each selection to the end of its line while
# preserving the selection's tail position. # preserving the selection's tail position.
# #
# This method may merge selections that end up intersecting. # This method may merge selections that end up intersecting.
selectToEndOfLine: -> selectToEndOfLine: ->
@expandSelectionsForward (selection) => selection.selectToEndOfLine() @expandSelectionsForward (selection) -> selection.selectToEndOfLine()
# Public: For each selection, move its cursor to the preceding word boundary # Public: For each selection, move its cursor to the preceding word boundary
# while maintaining the selection's tail position. # while maintaining the selection's tail position.
# #
# This method may merge selections that end up intersecting. # This method may merge selections that end up intersecting.
selectToPreviousWordBoundary: -> selectToPreviousWordBoundary: ->
@expandSelectionsBackward (selection) => selection.selectToPreviousWordBoundary() @expandSelectionsBackward (selection) -> selection.selectToPreviousWordBoundary()
# Public: For each selection, move its cursor to the next word boundary while # Public: For each selection, move its cursor to the next word boundary while
# maintaining the selection's tail position. # maintaining the selection's tail position.
# #
# This method may merge selections that end up intersecting. # This method may merge selections that end up intersecting.
selectToNextWordBoundary: -> selectToNextWordBoundary: ->
@expandSelectionsForward (selection) => selection.selectToNextWordBoundary() @expandSelectionsForward (selection) -> selection.selectToNextWordBoundary()
# Public: For each cursor, select the containing line. # Public: For each cursor, select the containing line.
# #
# This method merges selections on successive lines. # This method merges selections on successive lines.
selectLine: -> selectLine: ->
@expandSelectionsForward (selection) => selection.selectLine() @expandSelectionsForward (selection) -> selection.selectLine()
# Public: Add a similarly-shaped selection to the next eligible line below # Public: Add a similarly-shaped selection to the next eligible line below
# each selection. # each selection.
@@ -1764,7 +1764,7 @@ class Editor extends Model
# selection to the next line that is long enough for a non-empty selection # selection to the next line that is long enough for a non-empty selection
# starting at the same column as the current selection to be added to it. # starting at the same column as the current selection to be added to it.
addSelectionBelow: -> addSelectionBelow: ->
@expandSelectionsForward (selection) => selection.addSelectionBelow() @expandSelectionsForward (selection) -> selection.addSelectionBelow()
# Public: Add a similarly-shaped selection to the next eligible line above # Public: Add a similarly-shaped selection to the next eligible line above
# each selection. # each selection.
@@ -1775,7 +1775,7 @@ class Editor extends Model
# selection to the next line that is long enough for a non-empty selection # selection to the next line that is long enough for a non-empty selection
# starting at the same column as the current selection to be added to it. # starting at the same column as the current selection to be added to it.
addSelectionAbove: -> addSelectionAbove: ->
@expandSelectionsBackward (selection) => selection.addSelectionAbove() @expandSelectionsBackward (selection) -> selection.addSelectionAbove()
# Public: Split multi-line selections into one selection per line. # Public: Split multi-line selections into one selection per line.
# #
@@ -1800,7 +1800,7 @@ class Editor extends Model
# If the selection is empty, the characters preceding and following the cursor # If the selection is empty, the characters preceding and following the cursor
# are swapped. Otherwise, the selected characters are reversed. # are swapped. Otherwise, the selected characters are reversed.
transpose: -> transpose: ->
@mutateSelectedText (selection) => @mutateSelectedText (selection) ->
if selection.isEmpty() if selection.isEmpty()
selection.selectRight() selection.selectRight()
text = selection.getText() text = selection.getText()
@@ -1815,14 +1815,14 @@ class Editor extends Model
# For each selection, if the selection is empty, converts the containing word # For each selection, if the selection is empty, converts the containing word
# to upper case. Otherwise convert the selected text to upper case. # to upper case. Otherwise convert the selected text to upper case.
upperCase: -> upperCase: ->
@replaceSelectedText selectWordIfEmpty:true, (text) => text.toUpperCase() @replaceSelectedText selectWordIfEmpty:true, (text) -> text.toUpperCase()
# Public: Convert the selected text to lower case. # Public: Convert the selected text to lower case.
# #
# For each selection, if the selection is empty, converts the containing word # For each selection, if the selection is empty, converts the containing word
# to upper case. Otherwise convert the selected text to upper case. # to upper case. Otherwise convert the selected text to upper case.
lowerCase: -> lowerCase: ->
@replaceSelectedText selectWordIfEmpty:true, (text) => text.toLowerCase() @replaceSelectedText selectWordIfEmpty:true, (text) -> text.toLowerCase()
# Convert multiple lines to a single line. # Convert multiple lines to a single line.
# #
@@ -1840,39 +1840,39 @@ class Editor extends Model
# Operates on all selections. Moves the cursor to the beginning of the # Operates on all selections. Moves the cursor to the beginning of the
# containing word while preserving the selection's tail position. # containing word while preserving the selection's tail position.
selectToBeginningOfWord: -> selectToBeginningOfWord: ->
@expandSelectionsBackward (selection) => selection.selectToBeginningOfWord() @expandSelectionsBackward (selection) -> selection.selectToBeginningOfWord()
# Public: Expand selections to the end of their containing word. # Public: Expand selections to the end of their containing word.
# #
# Operates on all selections. Moves the cursor to the end of the containing # Operates on all selections. Moves the cursor to the end of the containing
# word while preserving the selection's tail position. # word while preserving the selection's tail position.
selectToEndOfWord: -> selectToEndOfWord: ->
@expandSelectionsForward (selection) => selection.selectToEndOfWord() @expandSelectionsForward (selection) -> selection.selectToEndOfWord()
# Public: Expand selections to the beginning of the next word. # Public: Expand selections to the beginning of the next word.
# #
# Operates on all selections. Moves the cursor to the beginning of the next # Operates on all selections. Moves the cursor to the beginning of the next
# word while preserving the selection's tail position. # word while preserving the selection's tail position.
selectToBeginningOfNextWord: -> selectToBeginningOfNextWord: ->
@expandSelectionsForward (selection) => selection.selectToBeginningOfNextWord() @expandSelectionsForward (selection) -> selection.selectToBeginningOfNextWord()
# Public: Select the word containing each cursor. # Public: Select the word containing each cursor.
selectWord: -> selectWord: ->
@expandSelectionsForward (selection) => selection.selectWord() @expandSelectionsForward (selection) -> selection.selectWord()
# Public: Expand selections to the beginning of the next paragraph. # Public: Expand selections to the beginning of the next paragraph.
# #
# Operates on all selections. Moves the cursor to the beginning of the next # Operates on all selections. Moves the cursor to the beginning of the next
# paragraph while preserving the selection's tail position. # paragraph while preserving the selection's tail position.
selectToBeginningOfNextParagraph: -> selectToBeginningOfNextParagraph: ->
@expandSelectionsForward (selection) => selection.selectToBeginningOfNextParagraph() @expandSelectionsForward (selection) -> selection.selectToBeginningOfNextParagraph()
# Public: Expand selections to the beginning of the next paragraph. # Public: Expand selections to the beginning of the next paragraph.
# #
# Operates on all selections. Moves the cursor to the beginning of the next # Operates on all selections. Moves the cursor to the beginning of the next
# paragraph while preserving the selection's tail position. # paragraph while preserving the selection's tail position.
selectToBeginningOfPreviousParagraph: -> selectToBeginningOfPreviousParagraph: ->
@expandSelectionsBackward (selection) => selection.selectToBeginningOfPreviousParagraph() @expandSelectionsBackward (selection) -> selection.selectToBeginningOfPreviousParagraph()
# Public: Select the range of the given marker if it is valid. # Public: Select the range of the given marker if it is valid.
# #

View File

@@ -39,14 +39,14 @@ class GutterView extends View
else else
editor.getSelection().setScreenRange([[startRow, 0], [startRow, 0]]) editor.getSelection().setScreenRange([[startRow, 0], [startRow, 0]])
moveHandler = (e) => moveHandler = (e) ->
start = startRow start = startRow
end = editorView.screenPositionFromMouseEvent(e).row end = editorView.screenPositionFromMouseEvent(e).row
if end > start then end++ else start++ if end > start then end++ else start++
editor.getSelection().setScreenRange([[start, 0], [end, 0]]) editor.getSelection().setScreenRange([[start, 0], [end, 0]])
$(document).on "mousemove.gutter-#{editorView.id}", moveHandler $(document).on "mousemove.gutter-#{editorView.id}", moveHandler
$(document).one "mouseup.gutter-#{editorView.id}", => $(document).off 'mousemove', moveHandler $(document).one "mouseup.gutter-#{editorView.id}", -> $(document).off 'mousemove', moveHandler
# Retrieves the containing {EditorView}. # Retrieves the containing {EditorView}.
# #
@@ -89,7 +89,7 @@ class GutterView extends View
# * klass: string class name # * klass: string class name
# #
# Returns true if the class was added to any lines # Returns true if the class was added to any lines
addClassToAllLines: (klass)-> addClassToAllLines: (klass) ->
elements = @getLineNumberElements() elements = @getLineNumberElements()
el.classList.add(klass) for el in elements el.classList.add(klass) for el in elements
!!elements.length !!elements.length
@@ -99,7 +99,7 @@ class GutterView extends View
# * klass: string class name. Can only be one class name. i.e. 'my-class' # * klass: string class name. Can only be one class name. i.e. 'my-class'
# #
# Returns true if the class was removed from any lines # Returns true if the class was removed from any lines
removeClassFromAllLines: (klass)-> removeClassFromAllLines: (klass) ->
# This is faster than calling $.removeClass on all lines, and faster than # This is faster than calling $.removeClass on all lines, and faster than
# making a new array and iterating through it. # making a new array and iterating through it.
elements = @getLineNumberElementsForClass(klass) elements = @getLineNumberElementsForClass(klass)
@@ -113,7 +113,7 @@ class GutterView extends View
# * klass: string class name # * klass: string class name
# #
# Returns true if there were lines the class was added to # Returns true if there were lines the class was added to
addClassToLine: (bufferRow, klass)-> addClassToLine: (bufferRow, klass) ->
elements = @getLineNumberElement(bufferRow) elements = @getLineNumberElement(bufferRow)
el.classList.add(klass) for el in elements el.classList.add(klass) for el in elements
!!elements.length !!elements.length
@@ -124,7 +124,7 @@ class GutterView extends View
# * klass: string class name # * klass: string class name
# #
# Returns true if there were lines the class was removed from # Returns true if there were lines the class was removed from
removeClassFromLine: (bufferRow, klass)-> removeClassFromLine: (bufferRow, klass) ->
classesRemoved = false classesRemoved = false
elements = @getLineNumberElement(bufferRow) elements = @getLineNumberElement(bufferRow)
for el in elements for el in elements

View File

@@ -181,13 +181,13 @@ class ReactEditorView extends View
getFontFamily: -> getFontFamily: ->
@component?.getFontFamily() @component?.getFontFamily()
setFontFamily: (fontFamily)-> setFontFamily: (fontFamily) ->
@component?.setFontFamily(fontFamily) @component?.setFontFamily(fontFamily)
getFontSize: -> getFontSize: ->
@component?.getFontSize() @component?.getFontSize()
setFontSize: (fontSize)-> setFontSize: (fontSize) ->
@component?.setFontSize(fontSize) @component?.setFontSize(fontSize)
setWidthInChars: (widthInChars) -> setWidthInChars: (widthInChars) ->

View File

@@ -381,7 +381,7 @@ class Selection extends Model
# options - A {Object} with the keys: # options - A {Object} with the keys:
# :autoIndent - If `true`, the line is indented to an automatically-inferred # :autoIndent - If `true`, the line is indented to an automatically-inferred
# level. Otherwise, {Editor::getTabText} is inserted. # level. Otherwise, {Editor::getTabText} is inserted.
indent: ({ autoIndent }={})-> indent: ({ autoIndent }={}) ->
{ row, column } = @cursor.getBufferPosition() { row, column } = @cursor.getBufferPosition()
if @isEmpty() if @isEmpty()