multi-file: allow to open an empty file.
This commit is contained in:
parent
eda850d9db
commit
32bcf8b985
|
@ -956,8 +956,16 @@ edit_edc_load(edit_data *ed, const char *file_path)
|
|||
strbuf_line = eina_strbuf_new();
|
||||
if (!strbuf_line) goto err;
|
||||
|
||||
eina_stringshare_del(ed->filepath);
|
||||
ed->filepath = eina_stringshare_add(file_path);
|
||||
|
||||
utf8_edit = eina_file_map_all(file, EINA_FILE_POPULATE);
|
||||
if (!utf8_edit) goto err;
|
||||
if (!utf8_edit)
|
||||
{
|
||||
ed->line_max = 0;
|
||||
ret = EINA_TRUE;
|
||||
goto err;
|
||||
}
|
||||
|
||||
//Check indentation.
|
||||
indent_data *id = syntax_indent_data_get(ed->sh);
|
||||
|
@ -1015,9 +1023,6 @@ edit_edc_load(edit_data *ed, const char *file_path)
|
|||
|
||||
ret = EINA_TRUE;
|
||||
|
||||
eina_stringshare_del(ed->filepath);
|
||||
ed->filepath = eina_stringshare_add(file_path);
|
||||
|
||||
err:
|
||||
//Even any text is not inserted, line number should start with 1
|
||||
if (ed->line_max == 0) line_init(ed);
|
||||
|
|
|
@ -386,7 +386,7 @@ _enventor_object_efl_file_file_set(Eo *obj EINA_UNUSED,
|
|||
fclose(fp);
|
||||
}
|
||||
|
||||
edit_load(pd->main_it->ed, file);
|
||||
if (!edit_load(pd->main_it->ed, file)) return EINA_FALSE;
|
||||
build_edc();
|
||||
edit_changed_set(pd->main_it->ed, EINA_FALSE);
|
||||
|
||||
|
@ -815,7 +815,13 @@ enventor_object_sub_item_add(Enventor_Object *obj, const char *file)
|
|||
it->ed = edit_init(obj, it);
|
||||
it->pd = pd;
|
||||
|
||||
edit_load(it->ed, file);
|
||||
if (!edit_load(it->ed, file))
|
||||
{
|
||||
edit_term(it->ed);
|
||||
free(it);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
edit_changed_set(it->ed, EINA_FALSE);
|
||||
edit_disabled_set(it->ed, EINA_TRUE);
|
||||
|
||||
|
@ -841,8 +847,13 @@ enventor_object_main_item_set(Enventor_Object *obj, const char *file)
|
|||
it->ed = edit_init(obj, it);
|
||||
it->pd = pd;
|
||||
|
||||
Eina_Bool ret = efl_file_set(obj, file, NULL);
|
||||
if (!ret) return NULL;
|
||||
if (!efl_file_set(obj, file, NULL))
|
||||
{
|
||||
edit_term(it->ed);
|
||||
pd->main_it = NULL;
|
||||
free(it);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return it;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue