Skip to content

Commit

Permalink
Fix WORDS_STARTING mode
Browse files Browse the repository at this point in the history
cf. #13
  • Loading branch information
leny committed May 27, 2016
1 parent b336885 commit a8e4dec
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/views/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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" );
}
}

Expand Down

0 comments on commit a8e4dec

Please sign in to comment.