Return false if either character is whitespace

This commit is contained in:
Kevin Sawicki
2013-09-27 15:27:11 -07:00
parent cd4e64a8f8
commit e2daef477c
2 changed files with 14 additions and 5 deletions

View File

@@ -456,6 +456,13 @@ describe "Editor", ->
editor.renderedLines.trigger 'mouseup'
expect(editor.getSelectedText()).toBe "items"
editor.setCursorBufferPosition([0, 0])
editor.renderedLines.trigger mousedownEvent(editor: editor, point: [0, 28], originalEvent: {detail: 1})
editor.renderedLines.trigger 'mouseup'
editor.renderedLines.trigger mousedownEvent(editor: editor, point: [0, 28], originalEvent: {detail: 2})
editor.renderedLines.trigger 'mouseup'
expect(editor.getSelectedText()).toBe "{"
describe "triple/quardruple/etc-click", ->
it "selects the line under the cursor", ->
expect(editor.getCursorScreenPosition()).toEqual(row: 0, column: 0)

View File

@@ -141,6 +141,9 @@ class Cursor
# character. The non-word characters are defined by the
# `editor.nonWordCharacters` config value.
#
# This method returns false if the character before or after the cursor is
# whitespace.
#
# Returns a Boolean.
isBetweenWordAndNonWord: ->
return false if @isAtBeginningOfLine() or @isAtEndOfLine()
@@ -148,11 +151,10 @@ class Cursor
{row, column} = @getBufferPosition()
range = [[row, column - 1], [row, column + 1]]
[before, after] = @editSession.getTextInBufferRange(range)
if before and after
nonWordCharacters = config.get('editor.nonWordCharacters').split('')
_.contains(nonWordCharacters, before) isnt _.contains(nonWordCharacters, after)
else
false
return false if /\s/.test(before) or /\s/.test(after)
nonWordCharacters = config.get('editor.nonWordCharacters').split('')
_.contains(nonWordCharacters, before) isnt _.contains(nonWordCharacters, after)
# Public: Returns whether this cursor is between a word's start and end.
isInsideWord: ->