summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--buffer.c4
-rw-r--r--config.c4
-rw-r--r--main.c3
-rw-r--r--ted-internal.h2
-rw-r--r--ted.c5
5 files changed, 13 insertions, 5 deletions
diff --git a/buffer.c b/buffer.c
index 039528e..6766a5a 100644
--- a/buffer.c
+++ b/buffer.c
@@ -534,6 +534,10 @@ Settings *buffer_settings(TextBuffer *buffer) {
return &buffer->settings;
}
+void buffer_recompute_settings(TextBuffer *buffer) {
+ buffer->settings_computed = false;
+}
+
u8 buffer_tab_width(TextBuffer *buffer) {
return buffer_settings(buffer)->tab_width;
}
diff --git a/config.c b/config.c
index 811fcc9..7518a3b 100644
--- a/config.c
+++ b/config.c
@@ -161,7 +161,7 @@ static const SettingKeyCombo settings_key_combo[] = {
bool config_applies_to(Config *cfg, const char *path, Language language) {
if (cfg->language && language != cfg->language)
return false;
- if (cfg->path && !str_has_path_prefix(path, cfg->path))
+ if (cfg->path && (!path || !str_has_path_prefix(path, cfg->path)))
return false;
return true;
}
@@ -264,6 +264,7 @@ void settings_free(Settings *settings) {
static bool all_set[sizeof(Settings)];
memset(all_set, 1, sizeof all_set);
settings_free_set(settings, all_set);
+ memset(settings, 0, sizeof *settings);
}
static void config_free(Config *cfg) {
@@ -984,7 +985,6 @@ static void config_read_file(Ted *ted, const char *cfg_path, const char ***inclu
cfg = arr_addp(ted->all_configs);
cfg->path = *path ? str_dup(path) : NULL;
cfg->language = language;
- printf("new config:%s(%u)\n",cfg->path,cfg->language);
}
} else if (line[0] == '%') {
if (str_has_prefix(line, "%include ")) {
diff --git a/main.c b/main.c
index c9348b8..78b3373 100644
--- a/main.c
+++ b/main.c
@@ -1,7 +1,7 @@
/*
TODO:
- switch back to starting file after rename
-- .editorconfig? see https://editorconfig.org/
+- .editorconfig (see https://editorconfig.org/)
FUTURE FEATURES:
- autodetect indentation (tabs vs spaces)
- custom file/build command associations
@@ -16,6 +16,7 @@ FUTURE FEATURES:
- manual directory
- restart LSP server automatically?
- LSP request timeout
+- reflow command
*/
#include "ted-internal.h"
diff --git a/ted-internal.h b/ted-internal.h
index 6fa49ae..4c36fef 100644
--- a/ted-internal.h
+++ b/ted-internal.h
@@ -442,6 +442,8 @@ LSPPosition buffer_cursor_pos_as_lsp_position(TextBuffer *buffer);
///
/// Returns `(LSPRange){0}` if nothing is selected.
LSPRange buffer_selection_as_lsp_range(TextBuffer *buffer);
+/// indicate that config has been reloaded so we need to recompute buffer settings
+void buffer_recompute_settings(TextBuffer *buffer);
/// Apply LSP TextEdit[] from response
void buffer_apply_lsp_text_edits(TextBuffer *buffer, const LSPResponse *response, const LSPTextEdit *edits, size_t n_edits);
/// Get the cursor position as an LSPDocumentPosition.
diff --git a/ted.c b/ted.c
index 06c3db1..e8608b2 100644
--- a/ted.c
+++ b/ted.c
@@ -225,7 +225,6 @@ static int applicable_configs_cmp(void *context, const void *av, const void *bv)
void ted_compute_settings(Ted *ted, const char *path, Language language, Settings *settings) {
settings_free(settings);
- memset(settings, 0, sizeof *settings);
u32 *applicable_configs = NULL;
for (u32 i = 0; i < arr_len(ted->all_configs); i++) {
Config *cfg = &ted->all_configs[i];
@@ -742,8 +741,10 @@ void ted_load_configs(Ted *ted) {
void ted_reload_configs(Ted *ted) {
config_free_all(ted);
ted_load_configs(ted);
- // reset text size
ted_load_fonts(ted);
+ arr_foreach_ptr(ted->buffers, TextBufferPtr, pbuf) {
+ buffer_recompute_settings(*pbuf);
+ }
}
void ted_press_key(Ted *ted, SDL_Keycode keycode, SDL_Keymod modifier) {