summaryrefslogtreecommitdiff
path: root/src/dged/buffers.c
diff options
context:
space:
mode:
authorAlbert Cervin <albert@acervin.com>2024-09-17 08:47:03 +0200
committerAlbert Cervin <albert@acervin.com>2025-11-01 22:11:14 +0100
commit4459b8b3aa9d73895391785a99dcc87134e80601 (patch)
treea5204f447a0b2b05f63504c7fe958ef9bbf1918a /src/dged/buffers.c
parent4689f3f38277bb64981fc960e8e384e2d065d659 (diff)
downloaddged-4459b8b3aa9d73895391785a99dcc87134e80601.tar.gz
dged-4459b8b3aa9d73895391785a99dcc87134e80601.tar.xz
dged-4459b8b3aa9d73895391785a99dcc87134e80601.zip
More lsp support
This makes the LSP support complete for now: - Completion - Diagnostics - Goto implementation/declaration - Rename - Documentation - Find references
Diffstat (limited to 'src/dged/buffers.c')
-rw-r--r--src/dged/buffers.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/dged/buffers.c b/src/dged/buffers.c
index d20be39..f6d197d 100644
--- a/src/dged/buffers.c
+++ b/src/dged/buffers.c
@@ -1,5 +1,6 @@
#include "buffers.h"
#include "buffer.h"
+#include "s8.h"
#include <stdbool.h>
#include <stdlib.h>
@@ -112,7 +113,7 @@ struct buffer *buffers_find(struct buffers *buffers, const char *name) {
struct buffer *buffers_find_by_filename(struct buffers *buffers,
const char *path) {
struct buffer_chunk *chunk = buffers->head;
- size_t pathlen = strlen(path);
+ struct s8 needle = s8(path);
while (chunk != NULL) {
for (uint32_t i = 0; i < buffers->chunk_size; ++i) {
if (!chunk->entries[i].occupied) {
@@ -124,8 +125,8 @@ struct buffer *buffers_find_by_filename(struct buffers *buffers,
continue;
}
- size_t bnamelen = strlen(b->filename);
- if (bnamelen == pathlen && memcmp(path, b->filename, bnamelen) == 0) {
+ struct s8 bname = s8(b->filename);
+ if (s8endswith(bname, needle)) {
return b;
}
}