nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 2445e775355f2571f41a7c32e8674df3510fcbf8
parent d64235eb6e7129a8a6c94076e2c7e2b30fa77db1
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Fri, 10 May 2024 11:27:08 +0200

files: avoid mistakenly setting the column number to a given line number

When the file 'foo:24' exists (but not 'foo') and the user wants to
use the colon notation to place the cursor on a certain line, then
nano would first interpret the given line number as a column number,
before noticing that 'foo' does not exist and then skipping the first
colon.  So, when such a misinterpretation occurs, the column number
needs to be reset to zero.

Diffstat:
Msrc/nano.c | 4+++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/nano.c b/src/nano.c @@ -2509,8 +2509,10 @@ int main(int argc, char **argv) memmove(colon - 1, colon, strlen(colon) + 1); else if (parse_line_column(colon + 1, &givenline, &givencol)) { *colon = '\0'; - if (stat(filename, &fileinfo) < 0) + if (stat(filename, &fileinfo) < 0) { *colon++ = ':'; + givencol = 0; + } } else ++colon; }