Commit d42ded15 authored by Sebastien Granjoux's avatar Sebastien Granjoux

Fix wrong line number (+1) when searching in editors

	* plugins/search/search-replace.c,
	plugins/search/search-replace_backend.c:
	Fix wrong line number (+1) when searching in editors

svn path=/trunk/; revision=4906
parent 20b58d2e
2009-03-28 Sébastien Granjoux <seb.sfo@free.fr>
* plugins/search/search-replace.c,
plugins/search/search-replace_backend.c:
Fix wrong line number (+1) when searching in editors
2009-03-28 Iasen Karakashev <ikarakashev@yahoo.com>
reviewed by: Sébastien Granjoux <seb.sfo@free.fr>
......@@ -654,9 +654,7 @@ write_message_pane(IAnjutaMessageView* view, FileBuffer *fb, SearchEntry *se,
int line = mi->line;
gchar *buf;
gchar *path = NULL;
if (se->type == SE_FILE)
++line;
if (fb->file != NULL)
{
gchar *dir_uri = NULL;
......
......@@ -222,32 +222,26 @@ file_buffer_new_from_uri (const gchar *uri)
static long
file_buffer_line_from_pos(FileBuffer *fb, gint pos)
{
gint lineno = -1;
g_return_val_if_fail(fb && pos >= 0, 1);
if (FB_FILE == fb->type)
{
GList *tmp;
gint lineno = 0;
if (fb->lines == NULL)
{
gint i;
/* First line starts at column 0 */
fb->lines = g_list_prepend(fb->lines, GINT_TO_POINTER(0));
lineno = 0;
for (i=0; i < fb->len; ++i)
{
if ('\n' == fb->buf[i] && '\0' != fb->buf[i+1])
{
fb->lines = g_list_prepend(fb->lines, GINT_TO_POINTER(i + 1));
if (0 == fb->line && fb->pos > i)
fb->line = lineno;
++ lineno;
}
}
fb->lines = g_list_reverse(fb->lines);
lineno = -1;
}
for (tmp = fb->lines; tmp; tmp = g_list_next(tmp))
......@@ -262,6 +256,7 @@ file_buffer_line_from_pos(FileBuffer *fb, gint pos)
{
IAnjutaIterable *position;
gint offset;
gint lineno;
offset = g_utf8_strlen (fb->buf, pos);
position = ianjuta_editor_get_position_from_offset (fb->te, offset, NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment