summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--buffer.c12
-rw-r--r--command.c9
-rw-r--r--command.h2
-rw-r--r--config.c2
4 files changed, 21 insertions, 4 deletions
diff --git a/buffer.c b/buffer.c
index 036398b..4a54ff8 100644
--- a/buffer.c
+++ b/buffer.c
@@ -276,15 +276,21 @@ Language buffer_language(TextBuffer *buffer) {
static long context_score(const char *path, Language lang, const SettingsContext *context) {
long score = 0;
- if (lang == context->language) {
- score += 10000;
+ if (context->language) {
+ if (lang == context->language) {
+ score += 10000;
+ } else {
+ // dont use this. it's language-specific and for the wrong language.
+ return INT_MIN;
+ }
}
if (context->path) {
if (path && str_has_prefix(path, context->path)) {
score += (long)strlen(context->path);
} else {
- score -= 100000;
+ // dont use this. it's path-specific and for the wrong path.
+ return INT_MIN;
}
}
diff --git a/command.c b/command.c
index 58a6004..51c5c24 100644
--- a/command.c
+++ b/command.c
@@ -111,7 +111,14 @@ void command_execute(Ted *ted, Command c, i64 argument) {
case CMD_SELECT_ALL:
if (buffer) buffer_select_all(buffer);
break;
-
+
+ case CMD_INSERT_TEXT: {
+ const char *str = arg_get_string(ted, argument);
+ if (str) {
+ buffer_insert_utf8_at_cursor(buffer, str);
+ }
+ }
+ break;
case CMD_TAB:
if (ted->replace && buffer == &ted->find_buffer) {
ted_switch_to_buffer(ted, &ted->replace_buffer);
diff --git a/command.h b/command.h
index e9faf71..734a104 100644
--- a/command.h
+++ b/command.h
@@ -30,6 +30,7 @@ ENUM_U16 {
CMD_SELECT_PAGE_DOWN,
// insertion
+ CMD_INSERT_TEXT, // insert text
CMD_TAB, // insert '\t'
CMD_BACKTAB,
CMD_NEWLINE, // insert '\n' + autoindent -- also used to submit line buffers
@@ -134,6 +135,7 @@ static CommandName const command_names[] = {
{"page-down", CMD_PAGE_DOWN},
{"tab", CMD_TAB},
{"backtab", CMD_BACKTAB},
+ {"insert-text", CMD_INSERT_TEXT},
{"newline", CMD_NEWLINE},
{"newline-back", CMD_NEWLINE_BACK},
{"comment-selection", CMD_COMMENT_SELECTION},
diff --git a/config.c b/config.c
index ed77810..fdbd05f 100644
--- a/config.c
+++ b/config.c
@@ -787,7 +787,9 @@ void config_free(Ted *ted) {
}
for (u32 i = 0; i < ted->nstrings; ++i) {
free(ted->strings[i]);
+ ted->strings[i] = NULL;
}
+ ted->nstrings = 0;
arr_clear(ted->all_settings);
ted->default_settings = NULL;
}