summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ide-autocomplete.c14
-rw-r--r--main.c3
-rw-r--r--tags.c8
-rw-r--r--ted.h2
4 files changed, 14 insertions, 13 deletions
diff --git a/ide-autocomplete.c b/ide-autocomplete.c
index 1046364..4443c2b 100644
--- a/ide-autocomplete.c
+++ b/ide-autocomplete.c
@@ -183,19 +183,22 @@ static void autocomplete_find_completions(Ted *ted, uint32_t trigger, bool phant
} else {
// tag completion
autocomplete_clear_completions(ac);
+ autocomplete_clear_phantom(ac);
char *word_at_cursor = str32_to_utf8_cstr(buffer_word_at_cursor(buffer));
if (phantom) {
- char *completion = NULL;
- if (tags_beginning_with(ted, word_at_cursor, &completion, 1) == 1) {
+ char *completions[2] = {NULL, NULL};
+ if (tags_beginning_with(ted, word_at_cursor, completions, 2, false) == 1) {
// show phantom
- ac->phantom = completion;
+ ac->phantom = completions[0];
+ free(completions[1]);
} else {
- free(completion);
+ free(completions[0]);
+ free(completions[1]);
}
} else {
char **completions = calloc(TAGS_MAX_COMPLETIONS, sizeof *completions);
- u32 ncompletions = (u32)tags_beginning_with(ted, word_at_cursor, completions, TAGS_MAX_COMPLETIONS);
+ u32 ncompletions = (u32)tags_beginning_with(ted, word_at_cursor, completions, TAGS_MAX_COMPLETIONS, true);
arr_set_len(ac->completions, ncompletions);
@@ -396,7 +399,6 @@ static void autocomplete_find_phantom(Ted *ted) {
TextBuffer *buffer = ted->active_buffer;
if (!buffer->path) return;
if (buffer->view_only) return;
-
autocomplete_find_completions(ted, TRIGGER_INVOKED, true);
}
diff --git a/main.c b/main.c
index 7d9c287..beb0acd 100644
--- a/main.c
+++ b/main.c
@@ -1,8 +1,5 @@
/*
@TODO:
-- make tags_dir the root folder
-- check that tags still works
- - check that phantom completions works with tags
- do we need higher than 1-second resolution in time_last_modified on windows?
- when searching files, put exact matches at the top
- TESTING: make rust-analyzer-slow (waits 10s before sending response)
diff --git a/tags.c b/tags.c
index 6dd20d3..16c005a 100644
--- a/tags.c
+++ b/tags.c
@@ -101,7 +101,9 @@ static void tags_generate_at_dir(Ted *ted, bool run_in_build_window, const char
void tags_generate(Ted *ted, bool run_in_build_window) {
const char *filename = tags_filename(ted, false);
if (!filename) {
- strcpy(ted->tags_dir, ted->cwd);
+ char *root = ted_get_root_dir(ted);
+ strcpy(ted->tags_dir, root);
+ free(root);
}
change_directory(ted->tags_dir);
strcpy(ted->build_dir, ted->tags_dir);
@@ -136,9 +138,9 @@ static int tag_try(FILE *fp, const char *tag) {
return -1;
}
-size_t tags_beginning_with(Ted *ted, const char *prefix, char **out, size_t out_size) {
+size_t tags_beginning_with(Ted *ted, const char *prefix, char **out, size_t out_size, bool error_if_tags_does_not_exist) {
assert(out_size);
- const char *tags_name = tags_filename(ted, true);
+ const char *tags_name = tags_filename(ted, error_if_tags_does_not_exist);
if (!tags_name) return 0;
FILE *file = fopen(tags_name, "rb");
if (!file) return 0;
diff --git a/ted.h b/ted.h
index 270adff..bc99123 100644
--- a/ted.h
+++ b/ted.h
@@ -1265,7 +1265,7 @@ void tags_generate(Ted *ted, bool run_in_build_window);
// you may pass NULL for `out`, in which case just the number of matching tags is returned
// (still maxing out at `out_size`).
// each element in `out` should be freed when you're done with them.
-size_t tags_beginning_with(Ted *ted, const char *prefix, char **out, size_t out_size);
+size_t tags_beginning_with(Ted *ted, const char *prefix, char **out, size_t out_size, bool error_if_tags_does_not_exist);
// go to the definition of the given tag
bool tag_goto(Ted *ted, const char *tag);
// get all tags in the tags file as SymbolInfos.