Skip to content
This repository was archived by the owner on Apr 6, 2018. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/motions/general-motions.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,18 @@ class MoveToNextWord extends Motion
wordRegex: null
operatesInclusively: false

wordRegExp: (cursor, {includeNonWordCharacters}={}) ->
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this method ever called with a second argument? I only see the one call on line 215.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I just copied cursor's regex function: https://github.com/atom/atom/blob/37cb6b6d9e2be35af51b4e7e812b833efc24ce11/src/cursor.coffee#L642. My original intent was to merge the changes back to Atom.

includeNonWordCharacters ?= true
nonWordCharacters = atom.config.get('editor.nonWordCharacters', scope: cursor.getScopeDescriptor())
segments = ["^[\t ]*$"]
segments.push("[^\\s#{_.escapeRegExp(nonWordCharacters)}]+")
segments.push("$")
if includeNonWordCharacters
segments.push("[#{_.escapeRegExp(nonWordCharacters)}]+")
new RegExp(segments.join("|"), "g")

moveCursor: (cursor, count=1, options) ->
@wordRegex = @wordRegExp(cursor) if options?.allowEOL
_.times count, =>
current = cursor.getBufferPosition()

Expand Down
1 change: 1 addition & 0 deletions lib/operators/general-operators.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class Delete extends Operator
@complete = false
@selectOptions ?= {}
@selectOptions.requireEOL ?= true
@selectOptions.allowEOL ?= true
@register = settings.defaultRegister()

# Public: Deletes the text selected by the given motion.
Expand Down
7 changes: 4 additions & 3 deletions spec/operators-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,10 @@ describe "Operators", ->
keydown('w')

# Incompatibility with VIM. In vim, `w` behaves differently as an
# operator than as a motion; it stops at the end of a line.expect(editor.getText()).toBe "abcd abc"
expect(editor.getText()).toBe "abcd abc"
expect(editor.getCursorScreenPosition()).toEqual [0, 5]
# operator than as a motion; it stops at the end of a line
# and removes the preceding space: `expect(editor.getText()).toBe "abcd\nabc"`
expect(editor.getText()).toBe "abcd \nabc"
expect(editor.getCursorScreenPosition()).toEqual [0, 4]

expect(editorElement.classList.contains('operator-pending-mode')).toBe(false)
expect(editorElement.classList.contains('command-mode')).toBe(true)
Expand Down