commit 9c4488bf0c6586fee7bc9279427e219435f2c02c
parent 5ab12ca761ead41f32370ff439d7bc37abb78ff1
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date: Tue, 20 Sep 2005 19:36:39 +0000
in break_line(), fix another problem where goal could be miscalculated
on lines containing tabs
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3026 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -317,8 +317,9 @@ CVS code -
do_enter()
- Don't update the edit window until we set placewewant. (DLR)
break_line()
- - Fix a problem where a line could be broken in the middle of
- a multibyte character. (DLR)
+ - Fix problems where a line could be broken in the middle of
+ a multibyte character, and goal could be miscalculated on lines
+ containing tabs. (DLR)
do_word_count()
- Rename to do_wordlinechar_count(), and expand to also count
the number of lines and characters in the file or selection,
diff --git a/src/text.c b/src/text.c
@@ -570,12 +570,16 @@ ssize_t break_line(const char *line, ssize_t goal, bool newline)
* found with short enough display width. */
ssize_t cur_loc = 0;
/* Current index in line. */
+ size_t pos = 0;
+ /* Current column position in line. */
+ size_t old_pos;
+ /* Previous column position in line. */
int line_len;
assert(line != NULL);
while (*line != '\0' && goal >= 0) {
- size_t pos = 0;
+ old_pos = pos;
line_len = parse_mbchar(line, NULL, &pos);
@@ -586,7 +590,7 @@ ssize_t break_line(const char *line, ssize_t goal, bool newline)
break;
}
- goal -= pos;
+ goal -= pos - old_pos;
line += line_len;
cur_loc += line_len;
}