Do not discard last empty lines

master
Yevgen Muntyan 2007-11-26 02:45:08 -06:00
parent 1d477b367c
commit 103b32915d
3 changed files with 10 additions and 22 deletions

View File

@ -128,18 +128,7 @@ static gboolean
line_is_empty_or_comment (const char *line, line_is_empty_or_comment (const char *line,
gsize line_len) gsize line_len)
{ {
gsize i; return line_len == 0 || line[0] == '#';
for (i = 0; i < line_len; ++i)
{
if (line[i] == '#')
return TRUE;
if (!CHAR_IS_SPACE (line[i]))
return FALSE;
}
return TRUE;
} }
static guint static guint
@ -169,6 +158,8 @@ line_is_blank (const char *line,
{ {
guint i; guint i;
*indent = line_len;
for (i = 0; i < line_len; ++i) for (i = 0; i < line_len; ++i)
{ {
if (!CHAR_IS_SPACE (line[i])) if (!CHAR_IS_SPACE (line[i]))
@ -282,12 +273,7 @@ parse_content (Parser *parser,
line = parser->ptr; line = parser->ptr;
get_line (line, parser->len, &line_len, &next_line); get_line (line, parser->len, &line_len, &next_line);
if (line_is_blank (line, line_len, &indent_here)) line_is_blank (line, line_len, &indent_here);
{
g_string_append (content, "\n");
parser_next_line (parser, next_line);
continue;
}
if (!indent_here) if (!indent_here)
break; break;

View File

@ -6,6 +6,9 @@ from moo.utils import _
class PyCmd(moo.edit.Command): class PyCmd(moo.edit.Command):
def __init__(self, code, options): def __init__(self, code, options):
moo.edit.Command.__init__(self) moo.edit.Command.__init__(self)
if code and code[-1] != '\n' and code[-1] != '\r':
self.code = code + '\n'
else:
self.code = code self.code = code
self.set_options(options) self.set_options(options)

View File

@ -1816,10 +1816,9 @@ _moo_splitlines (const char *string)
} }
} }
if (p > line)
g_ptr_array_add (array, g_strndup (line, p - line)); g_ptr_array_add (array, g_strndup (line, p - line));
g_ptr_array_add (array, NULL); g_ptr_array_add (array, NULL);
return (char**) g_ptr_array_free (array, FALSE); return (char**) g_ptr_array_free (array, FALSE);
} }