From 146273afd869cd79a43daeadb97f83b07f6c85b2 Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Mon, 5 Jan 2026 15:01:43 +0100 Subject: [PATCH] ExcludePatterns for OpenCode --- src/backup/todo.txt | 1 - src/text_editor/commands.cpp | 16 +++++++++++++--- src/text_editor/globals.cpp | 1 + 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/backup/todo.txt b/src/backup/todo.txt index e0d624b..9bfc31b 100644 --- a/src/backup/todo.txt +++ b/src/backup/todo.txt @@ -2,7 +2,6 @@ ! From a user (novice) point of view, how does it look like? - We need regex for: [FormatCode matching, IsCode matching, -- Project config - IndentKind has issues with stuff still like cleaning whitespace etc. - Remedybg commands integrated! (like clicking f5 and opening up the window) - Macros diff --git a/src/text_editor/commands.cpp b/src/text_editor/commands.cpp index 7708c38..48705ef 100644 --- a/src/text_editor/commands.cpp +++ b/src/text_editor/commands.cpp @@ -833,24 +833,34 @@ void CMD_SetWorkDirHere() { void Coro_OpenCode(mco_coro *co) { Array patterns = SplitWhitespace(CoCurr->arena, OpenCodePatterns); + Array exclude_patterns = SplitWhitespace(CoCurr->arena, OpenCodeExcludePatterns); 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 should_open = true; if (!it.is_directory) { - bool should_open = false; + should_open = false; ForItem (ending, patterns) { if (EndsWith(it.absolute_path, ending)) { should_open = true; break; } } - if (!should_open) { - continue; + } + + ForItem (ending, exclude_patterns) { + if (EndsWith(it.absolute_path, ending)) { + should_open = false; + break; } } + if (!should_open) { + continue; + } + if (it.is_directory) { Add(&dirs, it.absolute_path); diff --git a/src/text_editor/globals.cpp b/src/text_editor/globals.cpp index 1d04fcb..fd6b3ae 100644 --- a/src/text_editor/globals.cpp +++ b/src/text_editor/globals.cpp @@ -168,6 +168,7 @@ RegisterVariable(Float, UndoMergeTime, 0.3); RegisterVariable(Float, JumpHistoryMergeTime, 0.3); RegisterVariable(String, InternetBrowser, "firefox"); 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(String, OpenCodeExcludePatterns, ""); RegisterVariable(Int, TrimTrailingWhitespace, 1); RegisterVariable(Int, FormatCode, 0); RegisterVariable(Int, SetModifiesConfig, 1); \ No newline at end of file