diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/kilo.c | 10 | ||||
-rw-r--r-- | src/lua.c | 4 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/kilo.c b/src/kilo.c index ac2e991..bc84948 100644 --- a/src/kilo.c +++ b/src/kilo.c @@ -972,6 +972,7 @@ void word_at_cursor(char* out, int capacity) { int cidx = E.coloff + E.cx; int len = 0; memset(out, 0, capacity); + if (row == NULL) return; /* scan back to first identifier char */ while (cidx > 0) { --cidx; @@ -989,15 +990,20 @@ void word_at_cursor(char* out, int capacity) { strncpy(out, &row->chars[cidx], len); } +/* Jump to some definition. */ extern void save_to_current_definition_and_editor_buffer(lua_State *L, char *name); extern void load_editor_buffer_to_current_definition_in_image(lua_State *L); +extern char Current_definition[]; #define CURRENT_DEFINITION_LEN 256 static void editorGo(lua_State* L) { char query[CURRENT_DEFINITION_LEN+1] = {0}; int qlen = 0; - editorSaveToDisk(); - load_editor_buffer_to_current_definition_in_image(L); + if (strlen(Current_definition) > 0) { + /* We're currently editing a definition. Save it. */ + editorSaveToDisk(); + load_editor_buffer_to_current_definition_in_image(L); + } word_at_cursor(query, CURRENT_DEFINITION_LEN); qlen = strlen(query); diff --git a/src/lua.c b/src/lua.c index 0a5b608..b17b7db 100644 --- a/src/lua.c +++ b/src/lua.c @@ -674,7 +674,6 @@ void recent_changes_view (lua_State *L) { /* refresh state after each operation so we pick up modifications */ lua_getglobal(L, "teliva_program"); history_array = lua_gettop(L); - assert(history_array == 1); history_array_size = luaL_getn(L, history_array); render_recent_changes(L, history_array, cursor, history_array_size); int c = getch(); @@ -692,7 +691,8 @@ void recent_changes_view (lua_State *L) { break; case CTRL_E: save_note_to_editor_buffer(L, cursor); - /* TODO: some hotkeys advertised but broken: go, big picture */ + /* big picture hotkey unnecessarily available here */ + /* TODO: go hotkey is misleading. edits will not be persisted until you return to recent changes */ edit(L, "teliva_editor_buffer", /*status message*/ ""); load_note_from_editor_buffer(L, cursor); save_image(L); |