Avoid double checks of bookmarks in editor.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2012-08-08 13:16:50 +04:00
parent 1b1071cdac
commit 37054596f6
2 changed files with 7 additions and 9 deletions

View File

@ -272,9 +272,10 @@ book_mark_flush (WEdit * edit, int c)
void void
book_mark_inc (WEdit * edit, long line) book_mark_inc (WEdit * edit, long line)
{ {
if (edit->book_mark) if (edit->book_mark != NULL)
{ {
struct _book_mark *p; struct _book_mark *p;
p = book_mark_find (edit, line); p = book_mark_find (edit, line);
for (p = p->next; p != NULL; p = p->next) for (p = p->next; p != NULL; p = p->next)
p->line++; p->line++;
@ -290,6 +291,7 @@ book_mark_dec (WEdit * edit, long line)
if (edit->book_mark != NULL) if (edit->book_mark != NULL)
{ {
struct _book_mark *p; struct _book_mark *p;
p = book_mark_find (edit, line); p = book_mark_find (edit, line);
for (p = p->next; p != NULL; p = p->next) for (p = p->next; p != NULL; p = p->next)
p->line--; p->line--;

View File

@ -2674,8 +2674,7 @@ edit_insert (WEdit * edit, int c)
/* now we must update some info on the file and check if a redraw is required */ /* now we must update some info on the file and check if a redraw is required */
if (c == '\n') if (c == '\n')
{ {
if (edit->book_mark) book_mark_inc (edit, edit->curs_line);
book_mark_inc (edit, edit->curs_line);
edit->curs_line++; edit->curs_line++;
edit->total_lines++; edit->total_lines++;
edit->force |= REDRAW_LINE_ABOVE | REDRAW_AFTER_CURSOR; edit->force |= REDRAW_LINE_ABOVE | REDRAW_AFTER_CURSOR;
@ -2725,8 +2724,7 @@ edit_insert_ahead (WEdit * edit, int c)
edit_modification (edit); edit_modification (edit);
if (c == '\n') if (c == '\n')
{ {
if (edit->book_mark) book_mark_inc (edit, edit->curs_line);
book_mark_inc (edit, edit->curs_line);
edit->total_lines++; edit->total_lines++;
edit->force |= REDRAW_AFTER_CURSOR; edit->force |= REDRAW_AFTER_CURSOR;
} }
@ -2806,8 +2804,7 @@ edit_delete (WEdit * edit, const int byte_delete)
edit_modification (edit); edit_modification (edit);
if (p == '\n') if (p == '\n')
{ {
if (edit->book_mark) book_mark_dec (edit, edit->curs_line);
book_mark_dec (edit, edit->curs_line);
edit->total_lines--; edit->total_lines--;
edit->force |= REDRAW_AFTER_CURSOR; edit->force |= REDRAW_AFTER_CURSOR;
} }
@ -2873,8 +2870,7 @@ edit_backspace (WEdit * edit, const int byte_delete)
edit_modification (edit); edit_modification (edit);
if (p == '\n') if (p == '\n')
{ {
if (edit->book_mark) book_mark_dec (edit, edit->curs_line);
book_mark_dec (edit, edit->curs_line);
edit->curs_line--; edit->curs_line--;
edit->total_lines--; edit->total_lines--;
edit->force |= REDRAW_AFTER_CURSOR; edit->force |= REDRAW_AFTER_CURSOR;