From 8f4d3a218f1b391eb0044895a3d2dc02f5e2bf6a Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Mon, 5 Jan 2026 14:52:00 +0100 Subject: [PATCH] Improve OpenCode --- src/backup/todo.txt | 2 ++ src/text_editor/commands.cpp | 18 +++++++++++------- src/text_editor/globals.cpp | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/backup/todo.txt b/src/backup/todo.txt index d362599..e0d624b 100644 --- a/src/backup/todo.txt +++ b/src/backup/todo.txt @@ -9,6 +9,8 @@ - ctrl-e started doing no-ops again ... ?? - Window position: vscode opens in fullscreen and then remembers what position it was close in (could be a config option) - On Linux: Try to implement is_debugger_present() +- Probably shouldn't emit (Key pressed when ctrl etc. is not clicked!!) +- Brace, bracket, paren indenting? - OnUpdate view hooks! - OnSave buffer hooks which will execute the config on save diff --git a/src/text_editor/commands.cpp b/src/text_editor/commands.cpp index 9fcf28c..7708c38 100644 --- a/src/text_editor/commands.cpp +++ b/src/text_editor/commands.cpp @@ -832,20 +832,24 @@ void CMD_SetWorkDirHere() { } RegisterCommand(CMD_SetWorkDirHere, "", "Sets work directory to the directory of the current buffer, it also renames couple special buffers to make them accomodate the new WorkDir"); void Coro_OpenCode(mco_coro *co) { - Array patterns = Split(CoCurr->arena, OpenCodeCommandExcludePatterns, "|"); + Array patterns = SplitWhitespace(CoCurr->arena, OpenCodePatterns); Array dirs = {CoCurr->arena}; String *param_dir = (String *)CoCurr->user_ctx; Add(&dirs, *param_dir); for (int diri = 0; diri < dirs.len; diri += 1) { for (FileIter it = IterateFiles(CoCurr->arena, dirs[diri]); IsValid(it); Advance(&it)) { - bool match = false; - ForItem (ending, patterns) { - if (EndsWith(it.absolute_path, ending)) { - match = true; - break; + if (!it.is_directory) { + bool should_open = false; + ForItem (ending, patterns) { + if (EndsWith(it.absolute_path, ending)) { + should_open = true; + break; + } + } + if (!should_open) { + continue; } } - if (match) continue; if (it.is_directory) { diff --git a/src/text_editor/globals.cpp b/src/text_editor/globals.cpp index 409ddfa..1d04fcb 100644 --- a/src/text_editor/globals.cpp +++ b/src/text_editor/globals.cpp @@ -167,7 +167,7 @@ RegisterVariable(String, WindowsVCVarsPathToLoadDevEnviroment, "C:/Program Files RegisterVariable(Float, UndoMergeTime, 0.3); RegisterVariable(Float, JumpHistoryMergeTime, 0.3); RegisterVariable(String, InternetBrowser, "firefox"); -RegisterVariable(String, OpenCodeCommandExcludePatterns, ".git/|.obj|.o|.pdb|.exe|.ilk|.ttf|.ico|.gif|.jpg|.png|.spall|.dll|.so|.a|.lib|SDL/"); +RegisterVariable(String, OpenCodePatterns, ".c .h .cpp .hpp .cc .cxx .rs .go .zig .py .lua .js .ts .jsx .tsx .java .kt .swift .cs .rb .php .html .css .scss .sh .bash .zsh .sql .asm .s .cmake .make .json .yaml .toml .ini .txt .md .rst .Makefile .Dockerfile .gitignore .bashrc .zshrc"); RegisterVariable(Int, TrimTrailingWhitespace, 1); RegisterVariable(Int, FormatCode, 0); RegisterVariable(Int, SetModifiesConfig, 1); \ No newline at end of file