-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve word boundary algorithm to ignore previous spaces so that con…
…trol+arrow-keys will skip over repeated spaces
- Loading branch information
Showing
2 changed files
with
26 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package tui | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestCalculateWordBoundaries(t *testing.T) { | ||
require.Equal(t, []int{0, 3}, calculateWordBoundaries("foo")) | ||
require.Equal(t, []int{0, 3, 7}, calculateWordBoundaries("foo bar")) | ||
require.Equal(t, []int{0, 3, 7}, calculateWordBoundaries("foo-bar")) | ||
require.Equal(t, []int{0, 3, 7, 11}, calculateWordBoundaries("foo-bar baz")) | ||
require.Equal(t, []int{0, 3, 10, 16}, calculateWordBoundaries("foo-- -bar - baz")) | ||
require.Equal(t, []int{0, 3}, calculateWordBoundaries("foo ")) | ||
} |