ListCode improvements

This commit is contained in:
Krzosa Karol
2025-05-12 17:20:23 +02:00
parent 70858fdec5
commit 6aaff7573a

View File

@@ -1042,9 +1042,9 @@ int Lua_ToggleFullscreen(lua_State *L) {
return 0; return 0;
} }
void ListFilesRecursive(Buffer *buffer, String filename) { void ListFilesRecursive(Buffer *buffer, String dir) {
Scratch scratch(buffer->line_starts.allocator); Scratch scratch(buffer->line_starts.allocator);
for (FileIter it = IterateFiles(scratch, filename); IsValid(it); Advance(&it)) { for (FileIter it = IterateFiles(scratch, dir); IsValid(it); Advance(&it)) {
if (it.filename == ".git") { if (it.filename == ".git") {
continue; continue;
} }
@@ -1055,7 +1055,7 @@ void ListFilesRecursive(Buffer *buffer, String filename) {
if (!good) { if (!good) {
continue; continue;
} }
RawAppendf(buffer, "%.*s\n", FmtString(it.absolute_path)); RawAppendf(buffer, "%-100.*s %.*s\n", FmtString(it.absolute_path), FmtString(it.filename));
} }
} }
} }
@@ -1065,6 +1065,7 @@ void Command_ListCode(void) {
JumpGarbageBuffer(&main); JumpGarbageBuffer(&main);
ListFilesRecursive(main.buffer, WorkDir); ListFilesRecursive(main.buffer, WorkDir);
main.view->fuzzy_search = true; main.view->fuzzy_search = true;
Command_SelectRangeOneCursor(main.view, GetEndAsRange(main.buffer));
} }
int Lua_ListCode(lua_State *L) { int Lua_ListCode(lua_State *L) {
@@ -1087,6 +1088,7 @@ BSet Command_Exec(String cmd, String working_dir, bool set_active = true) {
Exec(set.view->id, true, cmd, working_dir); Exec(set.view->id, true, cmd, working_dir);
return set; return set;
} }
int Lua_C(lua_State *L) { int Lua_C(lua_State *L) {
String string = lua_tostring(L, 1); String string = lua_tostring(L, 1);
lua_pop(L, 1); lua_pop(L, 1);