Do not treat newlines special in bigword movements

Improves on #7328.

I believe this is the correct behavior, simply skip all whitespace before
a word. Try with

	./fish -C 'bind \ef forward-bigword; bind \eb backward-bigword; bind \ed kill-bigword; bind \cw backward-kill-bigword'

Also unrelated formatting fixes. I don't think a CI failure on unformatted
code is warranted but I wish it could do that behind the scenes.
This commit is contained in:
Johannes Altmanninger 2020-09-27 17:53:18 +02:00
parent 791d23502f
commit e8859b4ce2
2 changed files with 10 additions and 5 deletions

View file

@ -557,7 +557,7 @@ static void perf_convert_ascii() {
double start = timef();
const int iters = 1024;
for (int i=0; i < iters; i++) {
for (int i = 0; i < iters; i++) {
(void)str2wcstring(s);
}
double end = timef();
@ -2523,7 +2523,8 @@ static void test_1_word_motion(word_motion_t motion, move_word_style_t style,
static void test_word_motion() {
say(L"Testing word motion");
test_1_word_motion(word_motion_left, move_word_style_punctuation, L"^echo ^hello_^world.^txt^");
test_1_word_motion(word_motion_right, move_word_style_punctuation, L"^echo^ hello^_world^.txt^");
test_1_word_motion(word_motion_right, move_word_style_punctuation,
L"^echo^ hello^_world^.txt^");
test_1_word_motion(word_motion_left, move_word_style_punctuation,
L"echo ^foo_^foo_^foo/^/^/^/^/^ ^");
@ -2541,6 +2542,10 @@ static void test_word_motion() {
test_1_word_motion(word_motion_right, move_word_style_punctuation, L"^a^ bcd^");
test_1_word_motion(word_motion_right, move_word_style_punctuation, L"a^b^ cde^");
test_1_word_motion(word_motion_right, move_word_style_punctuation, L"^ab^ cde^");
test_1_word_motion(word_motion_right, move_word_style_whitespace, L"^^a-b-c^ d-e-f");
test_1_word_motion(word_motion_right, move_word_style_whitespace, L"^a-b-c^\n d-e-f^ ");
test_1_word_motion(word_motion_right, move_word_style_whitespace, L"^a-b-c^\n\nd-e-f^ ");
}
/// Test is_potential_path.

View file

@ -819,7 +819,7 @@ bool move_word_state_machine_t::consume_char_whitespace(wchar_t c) {
case s_always_one: {
consumed = true; // always consume the first character
// If it's not whitespace, only consume those from here.
if (!iswblank(c)) {
if (!iswspace(c)) {
state = s_graph;
} else {
// If it's whitespace, keep consuming whitespace until the graphs.
@ -828,7 +828,7 @@ bool move_word_state_machine_t::consume_char_whitespace(wchar_t c) {
break;
}
case s_blank: {
if (iswblank(c)) {
if (iswspace(c)) {
consumed = true; // consumed whitespace
} else {
state = s_graph;
@ -836,7 +836,7 @@ bool move_word_state_machine_t::consume_char_whitespace(wchar_t c) {
break;
}
case s_graph: {
if (!iswblank(c)) {
if (!iswspace(c)) {
consumed = true; // consumed printable non-space
} else {
state = s_end;