tweaks: normalize the indentation after the previous change

Also rewrap two lines, reshuffle three, and improve three comments.
master
Benno Schulenberg 2020-02-17 13:35:52 +01:00
parent b3faf353c9
commit 3c4a4b04ce
1 changed files with 33 additions and 36 deletions

View File

@ -1649,65 +1649,62 @@ void inject(char *burst, size_t count)
}
#endif
/* Encode an embedded NUL byte as 0x0A. */
/* Encode an embedded NUL byte as 0x0A. */
for (size_t index = 0; index < count; index++)
if (burst[index] == '\0')
burst[index] = '\n';
#ifndef NANO_TINY
/* Only add a new undo item when the current item is not an ADD or when
* the current typing is not contiguous with the previous typing. */
if (openfile->last_action != ADD ||
/* Only add a new undo item when the current item is not an ADD or when
* the current typing is not contiguous with the previous typing. */
if (openfile->last_action != ADD ||
openfile->current_undo->mark_begin_lineno != openfile->current->lineno ||
openfile->current_undo->mark_begin_x != openfile->current_x)
add_undo(ADD, NULL);
add_undo(ADD, NULL);
#endif
/* Make room for the new bytes and copy them into the line. */
openfile->current->data = charealloc(openfile->current->data,
current_len + count + 1);
memmove(openfile->current->data + openfile->current_x + count,
/* Make room for the new bytes and copy them into the line. */
openfile->current->data = charealloc(openfile->current->data,
current_len + count + 1);
memmove(openfile->current->data + openfile->current_x + count,
openfile->current->data + openfile->current_x,
current_len - openfile->current_x + 1);
strncpy(openfile->current->data + openfile->current_x,
burst, count);
openfile->totsize += mbstrlen(burst);
set_modified();
strncpy(openfile->current->data + openfile->current_x, burst, count);
#ifndef NANO_TINY
/* Note that current_x has not yet been incremented. */
if (openfile->current == openfile->mark &&
/* When the mark is to the right of the cursor, compensate its position. */
if (openfile->current == openfile->mark &&
openfile->current_x < openfile->mark_x)
openfile->mark_x += count;
openfile->mark_x += count;
/* When the cursor is on the top row and not on the first chunk
* of a line, adding text there might change the preceding chunk
* and thus require an adjustment of firstcolumn. */
if (openfile->current == openfile->edittop &&
openfile->firstcolumn > 0) {
ensure_firstcolumn_is_aligned();
refresh_needed = TRUE;
}
/* When the cursor is on the top row and not on the first chunk
* of a line, adding text there might change the preceding chunk
* and thus require an adjustment of firstcolumn. */
if (openfile->current == openfile->edittop && openfile->firstcolumn > 0) {
ensure_firstcolumn_is_aligned();
refresh_needed = TRUE;
}
#endif
/* If text was added to the magic line, create a new magic line. */
if (openfile->filebot == openfile->current && !ISSET(NO_NEWLINES)) {
new_magicline();
if (margin > 0)
refresh_needed = TRUE;
}
openfile->current_x += count;
openfile->current_x += count;
/* If we've added text to the magic line, create a new magic line. */
if (openfile->filebot == openfile->current && !ISSET(NO_NEWLINES)) {
new_magicline();
if (margin > 0)
refresh_needed = TRUE;
}
openfile->totsize += mbstrlen(burst);
set_modified();
#ifndef NANO_TINY
update_undo(ADD);
update_undo(ADD);
#endif
#ifdef ENABLE_WRAPPING
/* If text gets wrapped, the edit window needs a refresh. */
if (ISSET(BREAK_LONG_LINES) && do_wrap())
refresh_needed = TRUE;
/* Wrap the line when needed, and if so, schedule a refresh. */
if (ISSET(BREAK_LONG_LINES) && do_wrap())
refresh_needed = TRUE;
#endif
#ifndef NANO_TINY