mirror of
git://git.sv.gnu.org/nano.git
synced 2025-02-08 17:34:00 +03:00
execute: stay on the same line number when filtering the whole buffer
When the filter command makes just small, per-line changes, keeping the cursor at the same line number allows the user to observe the effect of the changes -- which is not possible when the cursor gets moved to the end of the buffer. This partially fulfills https://savannah.gnu.org/bugs/?57248.
This commit is contained in:
parent
d9cb12f6e3
commit
fcf598e797
@ -992,6 +992,7 @@ bool execute_command(const char *command)
|
||||
/* The pipes through which text will be written and read. */
|
||||
struct sigaction oldaction, newaction = {{0}};
|
||||
/* Original and temporary handlers for SIGINT. */
|
||||
ssize_t was_lineno = (openfile->mark ? 0 : openfile->current->lineno);
|
||||
const bool should_pipe = (command[0] == '|');
|
||||
FILE *stream;
|
||||
|
||||
@ -1105,8 +1106,11 @@ bool execute_command(const char *command)
|
||||
else
|
||||
read_file(stream, 0, "pipe", TRUE);
|
||||
|
||||
if (should_pipe && !ISSET(MULTIBUFFER))
|
||||
if (should_pipe && !ISSET(MULTIBUFFER)) {
|
||||
if (was_lineno)
|
||||
goto_line_posx(was_lineno, 0);
|
||||
add_undo(COUPLE_END, N_("filtering"));
|
||||
}
|
||||
|
||||
/* Wait for the external command (and possibly data sender) to terminate. */
|
||||
wait(NULL);
|
||||
|
Loading…
x
Reference in New Issue
Block a user