diff options
author | pommicket <pommicket@gmail.com> | 2022-07-29 16:05:56 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-07-29 16:05:56 -0400 |
commit | 12cc45bfcaa4c866f4509b6324a424048f3ddd29 (patch) | |
tree | 0df68f4d3d51f5468b3b1681b803e3a0c7f7d95d | |
parent | d9edd1f62fa620d3a8a42c80aec330065b794e14 (diff) |
fix reloading with text-size
-rw-r--r-- | buffer.c | 2 | ||||
-rw-r--r-- | main.c | 2 | ||||
-rw-r--r-- | syntax.c | 2 | ||||
-rw-r--r-- | ted.c | 9 | ||||
-rw-r--r-- | ted.h | 2 |
5 files changed, 11 insertions, 6 deletions
@@ -2182,7 +2182,7 @@ bool buffer_save(TextBuffer *buffer) { buffer->undo_history_write_pos = arr_len(buffer->undo_history); char const *name = buffer->filename ? path_filename(buffer->filename) : TED_UNTITLED; if (streq(name, "ted.cfg") && buffer_settings(buffer)->auto_reload_config) { - ted_load_configs(buffer->ted); + ted_load_configs(buffer->ted, true); } } return success; @@ -398,7 +398,7 @@ int main(int argc, char **argv) { PROFILE_TIME(misc_end) PROFILE_TIME(configs_start) - ted_load_configs(ted); + ted_load_configs(ted, false); if (ted_haserr(ted)) { strcpy(config_err, ted->error); ted_clearerr(ted); // clear the error so later things (e.g. loading font) don't detect an error @@ -1090,7 +1090,7 @@ static void syntax_highlight_javascript(SyntaxState *state, char32_t const *line // this is not foolproof for detecting regex literals // but should handle all "reasonable" uses of regex. bool is_regex = i == 0 // slash is first char in line - || (line[i-1] <= WCHAR_MAX && iswspace(line[i-1])) // slash preceded by space + || (line[i-1] <= WCHAR_MAX && iswspace((wint_t)line[i-1])) // slash preceded by space || (line[i-1] <= 128 && strchr(";({[=,:", (char)line[i-1])); // slash preceded by any of these characters if (is_regex) { in_string = true; @@ -354,8 +354,8 @@ static void ted_reload_all(Ted *ted) { } // load/reload configs -void ted_load_configs(Ted *ted) { - config_free(ted); +void ted_load_configs(Ted *ted, bool reloading) { + if (reloading) config_free(ted); // copy global config to local config char local_config_filename[TED_PATH_MAX]; @@ -386,4 +386,9 @@ void ted_load_configs(Ted *ted) { config_read(ted, global_config_filename, 1); config_read(ted, local_config_filename, 1); if (ted->search_cwd) config_read(ted, TED_CFG, 1); + + if (reloading) { + // reset text size + ted_load_fonts(ted); + } } @@ -404,7 +404,7 @@ void command_execute(Ted *ted, Command c, i64 argument); void ted_switch_to_buffer(Ted *ted, TextBuffer *buffer); // the settings of the active buffer, or the default settings if there is no active buffer Settings *ted_active_settings(Ted *ted); -void ted_load_configs(Ted *ted); +void ted_load_configs(Ted *ted, bool reloading); static TextBuffer *find_search_buffer(Ted *ted); void config_read(Ted *ted, const char *filename, int pass); void config_free(Ted *ted); |