Compare commits

..

4 Commits

Author SHA1 Message Date
Krzosa Karol
4ad9e6bf20 Try to bring back tests 2026-03-19 11:18:57 +01:00
Krzosa Karol
edb461bde8 Fix first build error navigation 2026-03-19 10:43:22 +01:00
Krzosa Karol
3c6153380d Fix process output truncation on POSIX 2026-03-19 10:33:56 +01:00
Krzosa Karol
7cfae9af92 add todos && build modification 2026-03-11 08:30:22 +01:00
8 changed files with 74 additions and 23 deletions

View File

@@ -16,8 +16,7 @@ if [ ! -e "src/external/SDL" ]; then
# cmake -S . -B build_linux -DCMAKE_BUILD_TYPE=Release -DSDL_PIPEWIRE=OFF # cmake -S . -B build_linux -DCMAKE_BUILD_TYPE=Release -DSDL_PIPEWIRE=OFF
cmake -S . -B build_linux -DSDL_PIPEWIRE=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr cmake -S . -B build_linux -DSDL_PIPEWIRE=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr
cd build_linux cd build_linux
make -j16 sudo make -j16 install
sudo make install
cd ../../../.. cd ../../../..
fi fi

View File

@@ -487,6 +487,7 @@ void GetEventsForFrame(Array<Event> *events) {
For (EventPlayback) { For (EventPlayback) {
Add(events, it); Add(events, it);
} }
EventPlayback.len = 0;
SDL_Event event; SDL_Event event;
if (WaitForEventsState) { if (WaitForEventsState) {

View File

@@ -45,7 +45,7 @@ BSet ExecBuild(String windows_cmd, String unix_cmd, String working_dir = Project
Exec(args); Exec(args);
} }
main.window->active_goto_list = build.view->id; main.window->active_goto_list = build.view->id;
main.window->goto_list_pos = 0; main.window->goto_list_pos = -1;
build.window->visible = true; build.window->visible = true;
return build; return build;
} }

View File

@@ -64,3 +64,7 @@ void Serialize(Buffer *buffer, Event *e) {
#undef X #undef X
SerializeEnd(buffer); SerializeEnd(buffer);
} }
void CMD_CopyEvents() {
SaveStringInClipboard(GetString(EventBuffer));
} RegisterCommand(CMD_CopyEvents, "ctrl-shift-alt-j", "Copy all the events from the EventBuffer");

40
src/plugin_tests.cpp Normal file
View File

@@ -0,0 +1,40 @@
bool Testing = true;
void Wait(mco_coro *co) {
Add(&EventPlayback, {EVENT_KIND_INVALID});
for (Event *event = Yield(co); event->kind != EVENT_KIND_INVALID; event = Yield(co)) {
}
}
void CO_FirstTest(mco_coro *co) {
Testing = true;
WaitForEvents = false;
{Event ev = {};ev.kind = EVENT_KEY_PRESS; ev.key = SDLK_RETURN; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; Add(&EventPlayback, ev);}
{Event ev = {};ev.kind = EVENT_KEY_PRESS; ev.key = SDLK_RETURN; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; Add(&EventPlayback, ev);}
{Event ev = {};ev.kind = EVENT_KEY_PRESS; ev.key = SDLK_RETURN; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; Add(&EventPlayback, ev);}
{Event ev = {};ev.kind = EVENT_KEY_PRESS; ev.key = SDLK_RETURN; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; Add(&EventPlayback, ev);}
{Event ev = {};ev.kind = EVENT_KEY_PRESS; ev.key = SDLK_RETURN; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; Add(&EventPlayback, ev);}
{Event ev = {};ev.kind = EVENT_KEY_PRESS; ev.key = SDLK_RETURN; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; Add(&EventPlayback, ev);}
{Event ev = {};ev.kind = EVENT_KEY_PRESS; ev.key = SDLK_RETURN; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; Add(&EventPlayback, ev);}
{Event ev = {};ev.kind = EVENT_KEY_PRESS; ev.key = SDLK_LSHIFT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.shift = 1; Add(&EventPlayback, ev);}
{Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.shift = 1; ev.text = "M"; Add(&EventPlayback, ev);}
{Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.text = "e"; Add(&EventPlayback, ev);}
{Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.text = "m"; Add(&EventPlayback, ev);}
{Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.text = "e"; Add(&EventPlayback, ev);}
{Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.text = "s"; Add(&EventPlayback, ev);}
{Event ev = {};ev.kind = EVENT_KEY_PRESS; ev.key = SDLK_SPACE; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; Add(&EventPlayback, ev);}
{Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.text = " "; Add(&EventPlayback, ev);}
{Event ev = {};ev.kind = EVENT_KEY_PRESS; ev.key = SDLK_LSHIFT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.shift = 1; Add(&EventPlayback, ev);}
{Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.text = "a"; Add(&EventPlayback, ev);}
{Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.text = "n"; Add(&EventPlayback, ev);}
{Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.text = "d"; Add(&EventPlayback, ev);}
{Event ev = {};ev.kind = EVENT_KEY_PRESS; ev.key = SDLK_SPACE; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; Add(&EventPlayback, ev);}
{Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.text = " "; Add(&EventPlayback, ev);}
{Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.text = "s"; Add(&EventPlayback, ev);}
{Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.text = "t"; Add(&EventPlayback, ev);}
{Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.text = "u"; Add(&EventPlayback, ev);}
{Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.text = "f"; Add(&EventPlayback, ev);}
{Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.text = "f"; Add(&EventPlayback, ev);}
Wait(co);
} RegisterCoroutineCommand(CO_FirstTest, "", "Basic tests");

View File

@@ -351,18 +351,15 @@ bool IsValid(Process *process) {
} }
int status = 0; int status = 0;
pollfd p = {}; pid_t result = waitpid(plat->pid, &status, WNOHANG);
p.fd = plat->child_stdout_read; if (result == 0) {
p.events = POLLRDHUP | POLLERR | POLLHUP | POLLNVAL; return true;
int res = poll(&p, 1, 0);
if (res > 0) {
pid_t result = waitpid(plat->pid, &status, 0);
Assert(result != -1);
process->exit_code = WEXITSTATUS(status);
return false;
} }
return true; Assert(result != -1);
process->exit_code = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
process->is_valid = false;
return false;
} }
void KillProcess(Process *process) { void KillProcess(Process *process) {
@@ -384,7 +381,7 @@ String PollStdout(Allocator allocator, Process *process, bool force_read) {
p.events = POLLIN; p.events = POLLIN;
int res = poll(&p, 1, 0); int res = poll(&p, 1, 0);
if (res > 0 || force_read) { if (res > 0 || force_read) {
result.len = read(plat->child_stdout_read, result.data, 4 * 4096); result.len = read(plat->child_stdout_read, result.data, 16 * 4096);
} }
return result; return result;
} }
@@ -471,10 +468,9 @@ void UpdateProcesses() {
View *view = GetView(it.args.output_view); View *view = GetView(it.args.output_view);
String poll = PollStdout(scratch, &it, false); String poll = PollStdout(scratch, &it, false);
if (poll.len) { if (poll.len > 0) {
Append(view, poll, it.args.scroll_to_end); Append(view, poll, it.args.scroll_to_end);
} } else if (!IsValid(&it)) {
if (!IsValid(&it)) {
ReportConsolef("process %lld exit code = %d", it.id, it.exit_code); ReportConsolef("process %lld exit code = %d", it.id, it.exit_code);
remove_item = true; remove_item = true;
} }

View File

@@ -1,8 +1,13 @@
/* /*
- [x] list_functions.sh and rg in general in the color mode is prinitng differently from terminal as well as output is truncated!
- [ ] Syntax for executing commands from root of project
- [ ] Fuzzy search over executed command ouput
- [ ] When inserting parenthesis and selection is there, put the parens on both sides? - [ ] When inserting parenthesis and selection is there, put the parens on both sides?
- [ ] KillProcess in console !!! - should also kill all the children ........... - [ ] KillProcess in console !!! - should also kill all the children ...........
- [ ] ctrl-e with these short main.c:290: breaks a little, need to first click ctrl-e and then alt-e to jump - [x] ctrl-e with these short main.c:290: breaks a little, need to first click ctrl-e and then alt-e to jump
- [ ] Use command window without special fuzzy search features to type commands and stuff for executing shell etc..
- [ ] Make a platform layer and separate SDL stuff out
- [x] ReplaceAll - heap-use-after-free address, how to debug? I think would be nice to iterate all buffer ids and their addresses along with the state - [x] ReplaceAll - heap-use-after-free address, how to debug? I think would be nice to iterate all buffer ids and their addresses along with the state
- [x] BRO, the caret teleports on linux when I press the arrow for too long - [x] BRO, the caret teleports on linux when I press the arrow for too long
@@ -125,6 +130,7 @@
#include "plugin_profiler.cpp" #include "plugin_profiler.cpp"
#include "plugin_file_commands.cpp" #include "plugin_file_commands.cpp"
#include "plugin_word_complete.cpp" #include "plugin_word_complete.cpp"
#include "plugin_tests.cpp"
#if OS_WASM #if OS_WASM
EM_JS(void, JS_SetMouseCursor, (const char *cursor_str), { EM_JS(void, JS_SetMouseCursor, (const char *cursor_str), {
@@ -835,7 +841,7 @@ void MainLoop() {
GetEventsForFrame(&FrameEvents); GetEventsForFrame(&FrameEvents);
For (FrameEvents) { For (FrameEvents) {
#if PLUGIN_RECORD_EVENTS #if PLUGIN_RECORD_EVENTS
if (it.kind != EVENT_UPDATE) { if (it.kind != EVENT_UPDATE && !Testing) {
Serialize(EventBuffer, &it); Serialize(EventBuffer, &it);
} }
#endif #endif
@@ -1098,7 +1104,6 @@ int main(int argc, char **argv, char **envp)
Open(argv[i]); Open(argv[i]);
} }
// if (Testing) InitTests();
#if PLUGIN_LOAD_VCVARS #if PLUGIN_LOAD_VCVARS
LoadVCVars(); LoadVCVars();
#endif #endif

View File

@@ -274,10 +274,16 @@ void GotoNextInList(Window *window, Int line_offset = 1) {
Buffer *buffer_goto = GetBuffer(view_goto->active_buffer); Buffer *buffer_goto = GetBuffer(view_goto->active_buffer);
int64_t pos = window->goto_list_pos; int64_t pos = window->goto_list_pos;
Int start_line = 0;
if (pos < 0) {
start_line = line_offset > 0 ? 0 : buffer_goto->line_starts.len - 1;
} else {
Int line = PosToLine(buffer_goto, pos); Int line = PosToLine(buffer_goto, pos);
start_line = line + line_offset;
}
bool opened = false; bool opened = false;
for (Int i = line + line_offset; i >= 0 && i < buffer_goto->line_starts.len; i += line_offset) { for (Int i = start_line; i >= 0 && i < buffer_goto->line_starts.len; i += line_offset) {
Range line_range = GetLineRangeWithoutNL(buffer_goto, i); Range line_range = GetLineRangeWithoutNL(buffer_goto, i);
String16 string_line = GetString(buffer_goto, line_range); String16 string_line = GetString(buffer_goto, line_range);