Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions geanylua/glspi_dlg.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ static gint glspi_message(lua_State* L)
case 2:
if (!lua_isstring(L, 2)) { return FAIL_STRING_ARG(2); }
arg2=lua_tostring(L, 2);
/* Fallthrough */
default:
if (!lua_isstring(L, 1)) { return FAIL_STRING_ARG(1); }
arg1=lua_tostring(L, 1);
Expand Down Expand Up @@ -280,6 +281,7 @@ static gint glspi_input(lua_State* L)
if (!lua_isstring(L, 2)) { return FAIL_STRING_ARG(2); }
arg2=lua_tostring(L, 2);
}
/* Fallthrough */
default:
if (!lua_isnil(L, 1)) {
if (!lua_isstring(L, 1)) { return FAIL_STRING_ARG(1); }
Expand Down
30 changes: 22 additions & 8 deletions geanylua/glspi_doc.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ static gint glspi_newfile(lua_State* L)
} else {
ft=filetypes_lookup_by_name(tmp);
}
/* Fallthrough */
default:
if (!lua_isstring(L, 1)) { return FAIL_STRING_ARG(1); }
fn=lua_tostring(L, 1);
Expand Down Expand Up @@ -102,7 +103,7 @@ static gint glspi_activate(lua_State* L)
}
} else if (lua_idx > 0) {
/* Positive number refers to the geany->documents_array index */
gint doc_idx = lua_idx - 1;
guint doc_idx = (guint) (lua_idx - 1);
if ((doc_idx < geany->documents_array->len) && documents[doc_idx]->is_valid) {
tab_idx = document_get_notebook_page(documents[doc_idx]);
}
Expand Down Expand Up @@ -208,11 +209,16 @@ static gint glspi_save(lua_State* L)
} else {
if (lua_isnumber(L,1)) {
gint idx=(gint)lua_tonumber(L,1)-1;
status=document_save_file(documents[idx], TRUE);
GeanyDocument *doc = document_index(idx);
if (DOC_VALID(doc)) {
status=document_save_file(doc, TRUE);
}
} else {
if (lua_isstring(L,1)) {
gint idx=filename_to_doc_idx(lua_tostring(L,1));
status=document_save_file(documents[idx], TRUE);
if (idx >= 0) {
status=document_save_file(documents[idx], TRUE);
}
} else { return FAIL_STR_OR_NUM_ARG(1); }
}
}
Expand Down Expand Up @@ -241,7 +247,10 @@ static gint glspi_open(lua_State* L)
}
}
if (!fn) {
status=document_reload_force(documents[idx],NULL) ? idx : -1;
GeanyDocument*doc=document_index(idx);
if (DOC_VALID(doc)) {
status=document_reload_force(doc,NULL) ? idx : -1;
}
} else {
guint len=geany->documents_array->len;
GeanyDocument*doc=document_open_file(fn,FALSE,NULL,NULL);
Expand All @@ -268,12 +277,17 @@ static gint glspi_close(lua_State* L)
status=document_close(document_get_current());
} else {
if (lua_isnumber(L,1)) {
guint idx=(guint)lua_tonumber(L,1)-1;
status=document_close(documents[idx]);
gint idx=(gint)lua_tonumber(L,1)-1;
GeanyDocument *doc = document_index(idx);
if (DOC_VALID(doc)) {
status=document_close(doc);
}
} else {
if (lua_isstring(L,1)) {
guint idx=(guint)filename_to_doc_idx(lua_tostring(L,1));
status=document_close(documents[idx]);
gint idx=filename_to_doc_idx(lua_tostring(L,1));
if (idx >= 0) {
status=document_close(documents[idx]);
}
} else { return FAIL_STR_OR_NUM_ARG(1); }
}
}
Expand Down
3 changes: 3 additions & 0 deletions geanylua/glspi_sci.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,16 +392,19 @@ static gint glspi_navigate(lua_State* L)
case 4:
if (!lua_isboolean(L,4)) { return FAIL_BOOL_ARG(4); }
rect=lua_toboolean(L,4);
/* Fallthrough */
case 3:
if (!lua_isboolean(L,3)) { return FAIL_BOOL_ARG(3); }
sel=lua_toboolean(L,3);
/* Fallthrough */
case 2:
if (!lua_isnumber(L,2)) { return FAIL_NUMERIC_ARG(2); }
count=lua_tonumber(L,2);
if (count<0) {
fwd=FALSE;
count=0-count;
}
/* Fallthrough */
case 1:
if (!lua_isstring(L,1)) { return FAIL_STRING_ARG(1); }
strcmd=lua_tostring(L,1);
Expand Down