From a8e4decdfe2677f38aded18204bfc8f7393ba6e7 Mon Sep 17 00:00:00 2001 From: leny Date: Sat, 28 May 2016 00:34:15 +0200 Subject: [PATCH] Fix WORDS_STARTING mode cf. #13 --- lib/views/input.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/views/input.js b/lib/views/input.js index 7600e16..617e3ef 100644 --- a/lib/views/input.js +++ b/lib/views/input.js @@ -273,7 +273,7 @@ class InputView extends View { rPositionRegExp = this.createLetterRegExp( this.sLetter ); break; case InputView.MODE_WORDS_STARTING: - rPositionRegExp = this.wordRegExp( this.sLetter ); + rPositionRegExp = this.startingLetterWordRegExp( this.sLetter ); break; case InputView.MODE_WORDS: default: @@ -344,10 +344,16 @@ class InputView extends View { return iRow === 0 || !this.oRefTextEditor.isFoldedAtBufferRow( iRow ) || !this.oRefTextEditor.isFoldedAtBufferRow( iRow - 1 ); } - wordRegExp( sStartingLetter = "" ) { + wordRegExp() { let sNonWordCharacters = atom.config.get( "editor.nonWordCharacters" ); - return new RegExp( `[${ sStartingLetter ? "" : "^" }\\s${ _.escapeRegExp( sNonWordCharacters ) }]+${ sStartingLetter }`, "gi" ); + return new RegExp( `[^\\s${ _.escapeRegExp( sNonWordCharacters ) }]+`, "gi" ); + } + + startingLetterWordRegExp( sStartingLetter ) { + let sNonWordCharacters = atom.config.get( "editor.nonWordCharacters" ); + + return new RegExp( `(?:^${ sStartingLetter }|[\\s${ _.escapeRegExp( sNonWordCharacters ) }]+${ sStartingLetter })`, "gi" ); } }