mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-10 10:17:11 +03:00
Merge pull request #9763 from dranzerashi/patch-1
This commit is contained in:
parent
c6cca659ab
commit
71d2761c1a
@ -767,6 +767,20 @@ describe "TextEditor", ->
|
||||
editor.moveToBeginningOfWord()
|
||||
expect(editor.getCursorBufferPosition()).toEqual [9, 2]
|
||||
|
||||
it "treats lines with only whitespace as a word (CRLF line ending)", ->
|
||||
editor.buffer.setText(buffer.getText().replace(/\n/g, "\r\n"))
|
||||
editor.setCursorBufferPosition([11, 0])
|
||||
editor.moveToBeginningOfWord()
|
||||
expect(editor.getCursorBufferPosition()).toEqual [10, 0]
|
||||
editor.buffer.setText(buffer.getText().replace(/\r\n/g, "\n"))
|
||||
|
||||
it "works when the current line is blank (CRLF line ending)", ->
|
||||
editor.buffer.setText(buffer.getText().replace(/\n/g, "\r\n"))
|
||||
editor.setCursorBufferPosition([10, 0])
|
||||
editor.moveToBeginningOfWord()
|
||||
expect(editor.getCursorBufferPosition()).toEqual [9, 2]
|
||||
editor.buffer.setText(buffer.getText().replace(/\r\n/g, "\n"))
|
||||
|
||||
describe ".moveToPreviousWordBoundary()", ->
|
||||
it "moves the cursor to the previous word boundary", ->
|
||||
editor.setCursorBufferPosition [0, 8]
|
||||
@ -826,6 +840,19 @@ describe "TextEditor", ->
|
||||
editor.moveToEndOfWord()
|
||||
expect(editor.getCursorBufferPosition()).toEqual [11, 8]
|
||||
|
||||
it "treats lines with only whitespace as a word (CRLF line ending)", ->
|
||||
editor.buffer.setText(buffer.getText().replace(/\n/g, "\r\n"))
|
||||
editor.setCursorBufferPosition([9, 4])
|
||||
editor.moveToEndOfWord()
|
||||
expect(editor.getCursorBufferPosition()).toEqual [10, 0]
|
||||
|
||||
it "works when the current line is blank (CRLF line ending)", ->
|
||||
editor.buffer.setText(buffer.getText().replace(/\n/g, "\r\n"))
|
||||
editor.setCursorBufferPosition([10, 0])
|
||||
editor.moveToEndOfWord()
|
||||
expect(editor.getCursorBufferPosition()).toEqual [11, 8]
|
||||
editor.buffer.setText(buffer.getText().replace(/\r\n/g, "\n"))
|
||||
|
||||
describe ".moveToBeginningOfNextWord()", ->
|
||||
it "moves the cursor before the first character of the next word", ->
|
||||
editor.setCursorBufferPosition [0, 6]
|
||||
|
@ -606,7 +606,7 @@ class Cursor extends Model
|
||||
wordRegExp: ({includeNonWordCharacters}={}) ->
|
||||
includeNonWordCharacters ?= true
|
||||
nonWordCharacters = @config.get('editor.nonWordCharacters', scope: @getScopeDescriptor())
|
||||
segments = ["^[\t ]*$"]
|
||||
segments = ["\\r?\\n[\\t\\s]*\\r?\\n"]
|
||||
segments.push("[^\\s#{_.escapeRegExp(nonWordCharacters)}]+")
|
||||
if includeNonWordCharacters
|
||||
segments.push("[#{_.escapeRegExp(nonWordCharacters)}]+")
|
||||
|
Loading…
Reference in New Issue
Block a user