From c1957249250c934ae0cf62cd1e445ccd2bdb9581 Mon Sep 17 00:00:00 2001
From: Yury V. Zaytsev <yury@shurup.com>
Date: Wed, 8 Sep 2010 21:43:11 +0200
Subject: [PATCH] Ticket #XXXX: Fix line jump when started as editor
Two common line jump protocols supported by mc are:
* mcedit +lineno file
* mcedit file:lineno
Unfortunately, in the implementation of the first protocol, if line
number equals to zero, which is often used to position the cursor at the
beginning of the file, it is completely ignored and file "+0" is opened
instead.
This patch fixes aforementioned issue.
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
---
src/main.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/src/main.c b/src/main.c
index 2be2a7f..2ff2bce 100644
a
|
b
|
mc_main__setup_by_args (int argc, char *argv[]) |
2050 | 2050 | try_plus_filename: |
2051 | 2051 | if (*tmp == '+' && g_ascii_isdigit ((gchar) tmp[1])) { |
2052 | 2052 | int start_line = atoi (tmp); |
| 2053 | |
| 2054 | /* |
| 2055 | * If start_line is zero, position the cursor at the |
| 2056 | * beginning of the file as other editors (vi, nano) |
| 2057 | */ |
| 2058 | if (start_line == 0) |
| 2059 | start_line++; |
| 2060 | |
2053 | 2061 | if (start_line > 0) { |
2054 | 2062 | char *file = (argc > 1) ? argv[2] : NULL; |
2055 | 2063 | if (file) { |