diff --git a/src/text_editor/buffer.h b/src/text_editor/buffer.h index 58b700a..ad33617 100644 --- a/src/text_editor/buffer.h +++ b/src/text_editor/buffer.h @@ -36,7 +36,6 @@ struct Buffer { int no_history : 1; int no_line_starts : 1; int dirty : 1; - int is_directory : 1; int gc : 1; int changed_on_disk : 1; }; diff --git a/src/text_editor/commands.cpp b/src/text_editor/commands.cpp index dceb510..bab04e6 100644 --- a/src/text_editor/commands.cpp +++ b/src/text_editor/commands.cpp @@ -83,7 +83,7 @@ void Command_ListBuffers() { Scratch scratch; Array strings = {scratch}; For(Buffers) { - String string = Format(scratch, "%.*s id=%d is_dir=%d", FmtString(it.o->name), (int)it.id, it.o->is_directory); + String string = Format(scratch, "%.*s id=%d", FmtString(it.o->name), (int)it.id); Add(&strings, string); } String result = Merge(scratch, strings, "\n"); diff --git a/src/text_editor/management.cpp b/src/text_editor/management.cpp index 0dda7b1..19a8c4b 100644 --- a/src/text_editor/management.cpp +++ b/src/text_editor/management.cpp @@ -244,13 +244,13 @@ String GetActiveMainWindowBufferName() { } String GetDir(Buffer *buffer) { - String name = buffer->is_directory ? buffer->name : ChopLastSlash(buffer->name); + String name = ChopLastSlash(buffer->name); return name; } String GetActiveMainWindowBufferDir() { BSet set = GetActiveMainSet(); - String name = set.buffer->is_directory ? set.buffer->name : ChopLastSlash(set.buffer->name); + String name = ChopLastSlash(set.buffer->name); return name; } @@ -330,8 +330,8 @@ Buffer *BufferOpenFile(String path) { if (!FileExists(path)) { buffer = CreateBuffer(sys_allocator, path); } else if (IsDir(path)) { - buffer = CreateBuffer(sys_allocator, path, 4096 * 2); - buffer->is_directory = true; + String buffer_name = GetUniqueBufferName(scratch, path, "+dir-"); + buffer = CreateBuffer(sys_allocator, buffer_name, 4096 * 2); for (FileIter it = IterateFiles(scratch, path); IsValid(it); Advance(&it)) { RawAppendf(buffer, "%.*s\n", FmtString(it.filename)); diff --git a/src/text_editor/todo.txt b/src/text_editor/todo.txt index 74756d8..a0f50cd 100644 --- a/src/text_editor/todo.txt +++ b/src/text_editor/todo.txt @@ -1,5 +1,4 @@ - maybe we could allow user to change window titles which would make them special in some way. -- decouple buffer magic and directory listing, we want names for directory listers - dump text editor state to file, restore state - help menu popup when for example in process buffer, on tile bar buffer and stuff like that