summaryrefslogtreecommitdiff
path: root/ted.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-08-07 07:19:56 -0400
committerpommicket <pommicket@gmail.com>2023-08-07 07:19:56 -0400
commitb146279b48f6a4f4bea8946cb3f0f1f5cc5a9985 (patch)
tree70069f2f622f3b6190fa1effcfb9ce9e14d8f94b /ted.c
parentbdbce6fe3c647616d22867bbc82e011c91231dd3 (diff)
handle more complicated renames
Diffstat (limited to 'ted.c')
-rw-r--r--ted.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/ted.c b/ted.c
index 14cc440..211a07b 100644
--- a/ted.c
+++ b/ted.c
@@ -575,6 +575,10 @@ static Status ted_open_buffer(Ted *ted, u16 *buffer_idx, u16 *tab) {
TextBuffer *ted_get_buffer_with_file(Ted *ted, const char *path) {
if (!path) return NULL;
+ if (!path_is_absolute(path)) {
+ assert(0);
+ return NULL;
+ }
bool *buffers_used = ted->buffers_used;
TextBuffer *buffers = ted->buffers;
@@ -879,3 +883,18 @@ void ted_remove_edit_notify(Ted *ted, EditNotifyID id) {
}
}
}
+
+void ted_close_buffer(Ted *ted, TextBuffer *buffer) {
+ if (!buffer) return;
+
+ u16 tab_idx=0;
+ Node *node = ted_buffer_location_in_node_tree(ted, buffer, &tab_idx);
+ node_tab_close(ted, node, tab_idx);
+}
+
+bool ted_close_buffer_with_file(Ted *ted, const char *path) {
+ TextBuffer *buffer = ted_get_buffer_with_file(ted, path);
+ if (!buffer) return false;
+ ted_close_buffer(ted, buffer);
+ return true;
+}