LogBuffer and NullBuffer separation, More indicators in status as new line as sep, eval multiple carets with Open, :Errors

This commit is contained in:
Krzosa Karol
2026-01-21 08:28:12 +01:00
parent 84c992c574
commit df963b0893
15 changed files with 159 additions and 149 deletions

1
.gitignore vendored
View File

@@ -6,6 +6,7 @@ src/external/SDL/
build/ build/
package/ package/
project.te
*.rdbg *.rdbg
*.spall *.spall
*.sublime-workspace *.sublime-workspace

View File

@@ -1 +0,0 @@
:OpenCode

View File

@@ -1,32 +1,17 @@
! What precise workflow do I need for me to be viable to use this? ! What precise workflow do I need for me to be viable to use this?
! From a user (novice) point of view, how does it look like? ! From a user (novice) point of view, how does it look like?
- Buffer edit history separate from caret history (tagging history blocks with carets???) - Buffer edit history separate from caret history (tagging history blocks with carets???)
- We need regex for: [FormatCode matching, IsCode matching, - We need regex for: [FormatCode matching, IsCode matching,
- Macros - Macros
- Window position: vscode opens in fullscreen and then remembers what position it was close in (could be a config option) - 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() - On Linux: Try to implement is_debugger_present()
- Maybe IPC for te.exe when it's already open and file arguments are passed it should perhaps open a buffer in current window?? - Maybe IPC for te.exe when it's already open and file arguments are passed it should perhaps open a buffer in current window??
Use session 4
- Add <<File>> <<ProjectDirectory>> template strings to Open (Then remove SEtWorkdirhere) - Add <<File>> <<ProjectDirectory>> template strings to Open (Then remove SEtWorkdirhere)
- :Set Filename to name current buffer ??? :O and others like that!! - :Set Filename to name current buffer ??? :O and others like that!!
- Make a fuzzy command !> grep and fuzzy over it??? (doesn't seem very useful for grep) - Make a fuzzy command !> grep and fuzzy over it??? (doesn't seem very useful for grep)
- Make the equivalent of SearchOpenBuffers but for cmds like !@git grep -n "@>" - Make the equivalent of SearchOpenBuffers but for cmds like !@git grep -n "@>"
- Add Bool variable - Add Bool variable
- RegisterCommand should_appear_in_listing variable
Use session 3:
- Maybe status view, commit changes (like to buffer name or line) on enter?
How to go about search/replace, opening code and other considerations
- Search and replace sign Find@>ReplaceWith
- We can use sed + find to search and replace, the automatic reopen should do the job
Use session 2
- Guide on the first page for new users with links to configs, tutorials - Guide on the first page for new users with links to configs, tutorials
Debug session: Debug session:
@@ -48,13 +33,10 @@ New UI Session
- Try to add Tracking Allocator and rewrite the app, free all memory at the end of the app and check all is well - Try to add Tracking Allocator and rewrite the app, free all memory at the end of the app and check all is well
backlog
FEATURE Some decl/function indexing in fuzzy format FEATURE Some decl/function indexing in fuzzy format
ISSUE? Fix jump scroll, the query ends up the last line on screen, kind of wacky
FEATURE dump text editor state to file, restore state FEATURE dump text editor state to file, restore state
- Search and replace - Search and replace
- word complete - word complete
- Search all buffers in 10X style, incrementally searched results popping up on every key press (maybe we need coroutine library in C so this is easier?)
- escapeing multiple cursor after ctrl + d should put the cursor where it was (probably will need to swap secondary and primary cursor for new cursor - escapeing multiple cursor after ctrl + d should put the cursor where it was (probably will need to swap secondary and primary cursor for new cursor
- draw indentation levels like in sublime (those lines) - we render chars one by one so seems relatively easy to figure out if whitespace belongs to beginning of line (make sure to add max value like 40 because of big files) - draw indentation levels like in sublime (those lines) - we render chars one by one so seems relatively easy to figure out if whitespace belongs to beginning of line (make sure to add max value like 40 because of big files)
- code sections, visual demarkation if beginning of line has a very specific text + goto next / goto prev section hotkey! - code sections, visual demarkation if beginning of line has a very specific text + goto next / goto prev section hotkey!

View File

@@ -1506,12 +1506,12 @@ Buffer *BufferOpenFile(String path) {
return buffer; return buffer;
} }
bool BufferIsReferenced(BufferID buffer_id) { bool BufferIsReferenced(Buffer *buffer) {
if (buffer_id == NullBufferID) { if (buffer->special) {
return true; return true;
} }
if (FindView(buffer_id, NULL)) { if (FindView(buffer->id, NULL)) {
return true; return true;
} }

View File

@@ -103,7 +103,7 @@ void ReportErrorf(const char *fmt, ...) {
BREAK(); BREAK();
} }
View *view = GetView(NullViewID); View *view = GetView(LogViewID);
if (view) { if (view) {
Appendf(view, "%S\n", string); Appendf(view, "%S\n", string);
} }
@@ -113,27 +113,21 @@ void ReportErrorf(const char *fmt, ...) {
void ReportConsolef(const char *fmt, ...) { void ReportConsolef(const char *fmt, ...) {
Scratch scratch; Scratch scratch;
STRING_FORMAT(scratch, fmt, string); STRING_FORMAT(scratch, fmt, string);
View *view = GetView(NullViewID); View *view = GetView(LogViewID);
Appendf(view, "%S\n", string); Appendf(view, "%S\n", string);
} }
void ReportWarningf(const char *fmt, ...) { void ReportWarningf(const char *fmt, ...) {
ErrorCount += 1;
Scratch scratch; Scratch scratch;
STRING_FORMAT(scratch, fmt, string); STRING_FORMAT(scratch, fmt, string);
if (BreakOnError) { if (BreakOnError) {
BREAK(); BREAK();
} }
View *null_view = GetView(NullViewID); View *null_view = GetView(LogViewID);
Appendf(null_view, "%S\n", string); Appendf(null_view, "%S\n", string);
} }
void CMD_OpenLoadWord() {
Scratch scratch;
BSet active = GetBSet(ActiveWindowID);
String16 load_word = FetchLoadWord(active.view);
Open(load_word);
} RegisterCommand(CMD_OpenLoadWord, "ctrl-q | f12", "Open a link under the caret (file link, url, command) or open the selection");
void CMD_CenterView() { void CMD_CenterView() {
CenterView(PrimaryWindowID); CenterView(PrimaryWindowID);
} RegisterCommand(CMD_CenterView, "", ""); } RegisterCommand(CMD_CenterView, "", "");
@@ -183,7 +177,7 @@ void ApplyFormattingTool(Buffer *buffer, String tool) {
if (exec_result.exit_code == 0) { if (exec_result.exit_code == 0) {
ReplaceWithoutMovingCarets(buffer, GetRange(buffer), string16); ReplaceWithoutMovingCarets(buffer, GetRange(buffer), string16);
} else { } else {
View *view = GetView(NullViewID); View *view = GetView(LogViewID);
Append(view, string16, true); Append(view, string16, true);
} }
} }
@@ -461,6 +455,11 @@ void CMD_ToggleFullscreen() {
} RegisterCommand(CMD_ToggleFullscreen, "f11", "Switches between the fullscreen and non-fulscreen mode"); } RegisterCommand(CMD_ToggleFullscreen, "f11", "Switches between the fullscreen and non-fulscreen mode");
void CMD_OpenLogs() { void CMD_OpenLogs() {
Buffer *buffer = GetBuffer(NullBufferID); ErrorCount = 0;
Buffer *buffer = GetBuffer(LogBufferID);
Open(buffer->name); Open(buffer->name);
} RegisterCommand(CMD_OpenLogs, "", "Opens the text editor logs"); } RegisterCommand(CMD_OpenLogs, "", "Opens the text editor logs and clear error counter");
void CMD_Errors() {
CMD_OpenLogs();
} RegisterCommand(CMD_Errors, "", "Opens the text editor logs and clear error counter");

View File

@@ -1,28 +1,3 @@
String16 FetchFuzzyViewLoadLine(View *view) {
Buffer *buffer = GetBuffer(view->active_buffer);
Range range = view->carets[0].range;
String16 string = GetString(buffer, range);
if (GetSize(range) == 0) {
Int line = PosToLine(buffer, range.min);
if (line == 0) {
line = ClampTop(1ll, buffer->line_starts.len - 1ll);
}
string = GetLineStringWithoutNL(buffer, line);
Int idx = 0;
String16 delim = u"||>";
if (Seek(string, delim, &idx, SeekFlag_None)) {
string = Skip(string, idx + delim.len);
}
}
return string;
}
void OpenCommand(BSet active) {
String16 string = FetchFuzzyViewLoadLine(active.view);
Open(string);
}
float NewFuzzyRate(String16 s, String16 p) { float NewFuzzyRate(String16 s, String16 p) {
float score = 0; float score = 0;
// try to do this: https://github.com/junegunn/fzf/blob/master/src/algo/algo.go // try to do this: https://github.com/junegunn/fzf/blob/master/src/algo/algo.go
@@ -124,13 +99,62 @@ void UpdateFuzzySearchView() {
} }
} }
void SetFuzzy(View *view) { String16 FetchFuzzyViewLoadLine(View *view) {
AddCommand(&view->commands, "Open", OpenKeySet, [](){ Buffer *buffer = GetBuffer(view->active_buffer);
BSet active = GetBSet(ActiveWindowID); Range range = view->carets[0].range;
BSet main = GetBSet(PrimaryWindowID); String16 string = GetString(buffer, range);
NextActiveWindowID = main.window->id; if (GetSize(range) == 0) {
Int line = PosToLine(buffer, range.min);
if (line == 0) {
line = ClampTop(1ll, buffer->line_starts.len - 1ll);
}
string = GetLineStringWithoutNL(buffer, line);
Int idx = 0;
String16 delim = u"||>";
if (Seek(string, delim, &idx, SeekFlag_None)) {
string = Skip(string, idx + delim.len);
}
}
return string;
}
void CMD_OpenLoadWord() {
Scratch scratch;
BSet active = GetBSet(ActiveWindowID);
For (active.view->carets) {
Range range = it.range;
if (GetSize(range) == 0) {
range = EncloseLoadWord(active.buffer, GetFront(it));
}
String16 load_word = GetString(active.buffer, range);
Open(load_word);
}
} RegisterCommand(CMD_OpenLoadWord, "ctrl-q | f12", "Open a link under the caret (file link, url, command) or open the selection");
void CMD_OpenForFuzzyView() {
BSet active = GetBSet(ActiveWindowID);
BSet main = GetBSet(PrimaryWindowID);
NextActiveWindowID = main.window->id;
if (active.view->carets.len == 1) {
String16 string = FetchFuzzyViewLoadLine(active.view); String16 string = FetchFuzzyViewLoadLine(active.view);
Open(string); Open(string);
}); } else {
CMD_OpenLoadWord();
}
}
void CMD_OpenAndSetGotoNext() {
BSet active = GetBSet(ActiveWindowID);
BSet main = GetBSet(PrimaryWindowID);
NextActiveWindowID = main.window->id;
String16 string = FetchFuzzyViewLoadLine(active.view);
main.window->active_goto_list = active.view->id;
main.window->goto_list_pos = active.view->carets[0].range.min;
Open(string);
}
void SetFuzzy(View *view) {
AddCommand(&view->commands, "Open", OpenKeySet, CMD_OpenForFuzzyView);
view->update_hook = UpdateFuzzySearchView; view->update_hook = UpdateFuzzySearchView;
} }

View File

@@ -9,6 +9,7 @@ bool RunGCThisFrame;
bool SearchCaseSensitive = false; bool SearchCaseSensitive = false;
bool SearchWordBoundary = false; bool SearchWordBoundary = false;
bool BreakOnError = false; bool BreakOnError = false;
Int ErrorCount;
Allocator SysAllocator = {SystemAllocatorProc}; Allocator SysAllocator = {SystemAllocatorProc};
String ConfigDir; String ConfigDir;
@@ -28,7 +29,9 @@ Array<Window *> Windows;
Array<View *> Views; Array<View *> Views;
Array<Buffer *> Buffers; Array<Buffer *> Buffers;
// First window BufferID LogBufferID;
ViewID LogViewID;
BufferID NullBufferID; BufferID NullBufferID;
ViewID NullViewID; ViewID NullViewID;
WindowID NullWindowID; WindowID NullWindowID;

View File

@@ -12,10 +12,6 @@ void CMD_ShowCommands() {
NextActiveWindowID = command_bar.window->id; NextActiveWindowID = command_bar.window->id;
ResetBuffer(command_bar.buffer); ResetBuffer(command_bar.buffer);
For (GlobalCommands) { For (GlobalCommands) {
if (it.name == "OpenCommand") {
continue;
}
// RawAppendf(command_bar.buffer, "\n:%-30S <|| :Set %-30S '%-30S'", it.name, it.name, it.binding);
RawAppendf(command_bar.buffer, "\n:%-30S <|| ", it.name); RawAppendf(command_bar.buffer, "\n:%-30S <|| ", it.name);
if (it.docs.len) { if (it.docs.len) {
RawAppendf(command_bar.buffer, "%S", it.docs); RawAppendf(command_bar.buffer, "%S", it.docs);

View File

@@ -59,12 +59,12 @@ void CMD_EvalCommandsLineByLine() {
BufferID LoadConfig(String config_path) { BufferID LoadConfig(String config_path) {
ReportConsolef("Loading config %S...", config_path); ReportConsolef("Loading config %S...", config_path);
Window *window = GetWindow(NullWindowID); Window *window = GetWindow(NullWindowID);
ViewID active_view_before = window->active_view;
View *view = WindowOpenBufferView(window, config_path); View *view = WindowOpenBufferView(window, config_path);
Buffer *buffer = GetBuffer(view->active_buffer); Buffer *buffer = GetBuffer(view->active_buffer);
buffer->special = true;
EvalCommandsLineByLine({window, view, buffer}); EvalCommandsLineByLine({window, view, buffer});
if (window->active_view == view->id) { if (window->active_view == view->id) {
window->active_view = NullViewID; window->active_view = active_view_before;
} }
return buffer->id; return buffer->id;
} }

View File

@@ -2131,7 +2131,7 @@ bool RDBG_InitConnection(mco_coro *co) {
String session_name = Format(CoCurr->arena, "te%llu", GetTimeNanos()); String session_name = Format(CoCurr->arena, "te%llu", GetTimeNanos());
String remedy_string = Format(CoCurr->arena, "%S --servername %S", RemedyBGPath, session_name); String remedy_string = Format(CoCurr->arena, "%S --servername %S", RemedyBGPath, session_name);
Exec(NullViewID, true, remedy_string, GetPrimaryDirectory()); Exec(LogViewID, true, remedy_string, GetPrimaryDirectory());
MemoryZero(&RDBG_Ctx, sizeof(RDBG_Ctx)); MemoryZero(&RDBG_Ctx, sizeof(RDBG_Ctx));
RDBG_Ctx.cmd.data = command_buf; RDBG_Ctx.cmd.data = command_buf;
RDBG_Ctx.cmd.capacity = sizeof(command_buf); RDBG_Ctx.cmd.capacity = sizeof(command_buf);
@@ -2157,23 +2157,27 @@ bool RDBG_InitConnection(mco_coro *co) {
} }
MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error)); MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error));
rdbg_Id cfg_id; if (EndsWith(file, ".rdbg")) {
char *exe = file.data; OpenSession(&RDBG_Ctx, file.data, &res);
char *args = NULL; } else {
char *work_dir = ProjectDirectory.data; rdbg_Id cfg_id;
char *env = NULL; char *exe = file.data;
AddSessionConfig(&RDBG_Ctx, exe, args, work_dir, env, true, true, &res, &cfg_id); char *args = NULL;
if (ContextHadError(&RDBG_Ctx)) { char *work_dir = ProjectDirectory.data;
ReportErrorf("Remedy error: %s", RDBG_Ctx.last_error); char *env = NULL;
MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error)); AddSessionConfig(&RDBG_Ctx, exe, args, work_dir, env, true, true, &res, &cfg_id);
return true; if (ContextHadError(&RDBG_Ctx)) {
} ReportErrorf("Remedy error: %s", RDBG_Ctx.last_error);
MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error));
return true;
}
SetActiveSessionConfig(&RDBG_Ctx, cfg_id, &res); SetActiveSessionConfig(&RDBG_Ctx, cfg_id, &res);
if (ContextHadError(&RDBG_Ctx)) { if (ContextHadError(&RDBG_Ctx)) {
ReportErrorf("Remedy error: %s", RDBG_Ctx.last_error); ReportErrorf("Remedy error: %s", RDBG_Ctx.last_error);
MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error)); MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error));
return true; return true;
}
} }
return true; return true;

View File

@@ -79,15 +79,7 @@ void CMD_SearchOpenBuffers() {
NextActiveWindowID = main.window->id; NextActiveWindowID = main.window->id;
JumpTempBuffer(&main); JumpTempBuffer(&main);
main.buffer->no_history = true; main.buffer->no_history = true;
AddCommand(&main.view->commands, "Open", OpenKeySet, []() { AddCommand(&main.view->commands, "Open", OpenKeySet, CMD_OpenAndSetGotoNext);
BSet active = GetBSet(ActiveWindowID);
BSet main = GetBSet(PrimaryWindowID);
NextActiveWindowID = main.window->id;
String16 string = FetchFuzzyViewLoadLine(active.view);
main.window->active_goto_list = active.view->id;
main.window->goto_list_pos = active.view->carets[0].range.min;
Open(string);
});
main.view->update_hook = UpdateSearchOpenBuffersView; main.view->update_hook = UpdateSearchOpenBuffersView;
if (string.len) { if (string.len) {
SelectRange(main.view, GetLineRangeWithoutNL(main.buffer, 0)); SelectRange(main.view, GetLineRangeWithoutNL(main.buffer, 0));

View File

@@ -29,58 +29,57 @@ void LayoutStatusWindow(Rect2I *rect, int16_t wx, int16_t wy) {
void UpdateStatusWindow() { void UpdateStatusWindow() {
ProfileFunction(); ProfileFunction();
Window *status_bar_window = GetWindow(StatusWindowID, NULL);
Scratch scratch; Scratch scratch;
BSet main = GetBSet(PrimaryWindowID); BSet main = GetBSet(PrimaryWindowID);
BSet title = GetBSet(status_bar_window); BSet title = GetBSet(StatusWindowID);
title.view->scroll.y = 0; title.view->scroll.y = 0;
if (title.window->id == ActiveWindowID) {
return;
}
#if 0
Vec2I doc_rect = GetSize(title.window->document_rect);
Int width_in_chars = doc_rect.x / title.window->font->char_spacing;
char buff[1024];
for (int i = 0; i < 1024; i += 1) buff[i] = ' ';
RawReplaceText(title.buffer, GetRange(title.buffer), u"");
RawAppendf(title.buffer, "%.*s", width_in_chars - 1, buff);
RawAppendf(title.buffer, "@");
return;
#endif
String16 buffer_string = GetString(title.buffer); String16 buffer_string = GetString(title.buffer);
Range replace_range = {0, title.buffer->len}; Range replace_range = {0, title.buffer->len};
bool found_separator = Seek(buffer_string, u" |", &replace_range.max); Seek(buffer_string, u"\n", &replace_range.max);
// Parse the title and line
if (title.window->id == ActiveWindowID) {
if (title.buffer->change_id == title.buffer->begin_frame_change_id) {
return;
}
String16 buffer_name = GetString(title.buffer, replace_range);
buffer_name = Trim(buffer_name);
Int column = ChopNumber(&buffer_name);
if (column == -1) return;
Chop(&buffer_name, u":");
Int line = ChopNumber(&buffer_name);
if (line == -1) {
line = column;
column = 0;
}
Chop(&buffer_name, u":");
Int buffer_pos = XYToPos(main.buffer, {column, line});
Caret &caret = main.view->carets[0];
if (GetFront(caret) != buffer_pos) {
caret = MakeCaret(buffer_pos);
}
return;
}
Caret caret = main.view->carets[0]; Caret caret = main.view->carets[0];
XY xy = PosToXY(main.buffer, GetFront(caret)); XY xy = PosToXY(main.buffer, GetFront(caret));
// add separator at the end of buffer String indicators = "";
if (!found_separator) { if (main.buffer->dirty) {
SelectRange(title.view, GetBufferEndAsRange(title.buffer)); indicators = Format(scratch, "%S!", indicators);
ReplaceEx(scratch, title.view, u" | :Prev :Next :Close"); }
if (SearchCaseSensitive) {
indicators = Format(scratch, "%SC", indicators);
}
if (SearchWordBoundary) {
indicators = Format(scratch, "%SW", indicators);
} }
// replace data up to separator with filename and stuff String commands = Format(scratch, ":Errors[%d]", ErrorCount);
const char *reopen = main.buffer->changed_on_disk ? " :Reopen" : ""; if (main.buffer->changed_on_disk) {
const char *case_sens = SearchCaseSensitive ? " C" : ""; commands = Format(scratch, "%S :Reopen");
const char *word_bound = SearchWordBoundary ? " W" : ""; }
const char *dirty = main.buffer->dirty ? " !" : ""; For (ActiveProcesses) {
String s = Format(scratch, "%S:%lld:%lld%s%s%s", main.buffer->name, (long long)xy.line + 1ll, (long long)xy.col + 1ll, dirty, case_sens, word_bound, reopen); if (it.view_id == main.view->id.id) {
commands = Format(scratch, "%S :KillProcess", commands);
break;
}
}
String s = Format(scratch, "%S:%lld:%lld %S | :Prev :Next :Close %S", main.buffer->name, (long long)xy.line + 1ll, (long long)xy.col + 1ll, indicators, commands);
For (ActiveProcesses) { For (ActiveProcesses) {
if (it.view_id == main.view->id.id) { if (it.view_id == main.view->id.id) {
s = Format(scratch, "%S %lld :KillProcess", s, (long long)it.id); s = Format(scratch, "%S %lld :KillProcess", s, (long long)it.id);

View File

@@ -506,7 +506,7 @@ void GarbageCollect() {
continue; continue;
} }
bool ref = ViewIsReferenced(it->id); bool ref = ViewIsReferenced(it);
if (ref) { if (ref) {
continue; continue;
} }
@@ -519,6 +519,7 @@ void GarbageCollect() {
#if PLUGIN_RECORD_GC #if PLUGIN_RECORD_GC
RawAppendf(GCInfoBuffer, "View %d %S\n", (int)it->id.id, buffer ? buffer->name : String{"NULL"}); RawAppendf(GCInfoBuffer, "View %d %S\n", (int)it->id.id, buffer ? buffer->name : String{"NULL"});
#endif #endif
Assert(it->special == false);
Dealloc(&it->commands); Dealloc(&it->commands);
Dealloc(it); Dealloc(it);
remove_item = true; remove_item = true;
@@ -536,7 +537,7 @@ void GarbageCollect() {
continue; continue;
} }
bool ref = BufferIsReferenced(it->id); bool ref = BufferIsReferenced(it);
if (ref) { if (ref) {
continue; continue;
} }
@@ -545,6 +546,7 @@ void GarbageCollect() {
#if PLUGIN_RECORD_GC #if PLUGIN_RECORD_GC
RawAppendf(GCInfoBuffer, "Buff %d %S\n", (int)it->id.id, it->name); RawAppendf(GCInfoBuffer, "Buff %d %S\n", (int)it->id.id, it->name);
#endif #endif
Assert(it->special == false);
remove_item = true; remove_item = true;
DeallocBuffer(it); DeallocBuffer(it);
} }
@@ -968,12 +970,19 @@ int main(int argc, char **argv)
{ {
Allocator sys_allocator = GetSystemAllocator(); Allocator sys_allocator = GetSystemAllocator();
Scratch scratch; Scratch scratch;
Buffer *null_buffer = CreateBuffer(sys_allocator, GetUniqueBufferName(ProjectDirectory, "logs", "")); Buffer *null_buffer = CreateBuffer(sys_allocator, GetUniqueBufferName(ProjectDirectory, "scratch", ""));
null_buffer->special = true; null_buffer->special = true;
View *null_view = CreateView(null_buffer->id); View *null_view = CreateView(null_buffer->id);
null_view->special = true; null_view->special = true;
Assert(null_buffer->id == NullBufferID && null_view->id == NullViewID); Assert(null_buffer->id == NullBufferID && null_view->id == NullViewID);
Buffer *logs_buffer = CreateBuffer(sys_allocator, GetUniqueBufferName(ProjectDirectory, "logs", ""));
logs_buffer->special = true;
LogBufferID = logs_buffer->id;
View *logs_view = CreateView(logs_buffer->id);
logs_view->special = true;
LogViewID = logs_view->id;
#if PLUGIN_RECORD_GC #if PLUGIN_RECORD_GC
GCInfoBuffer = CreateBuffer(sys_allocator, GetUniqueBufferName(ProjectDirectory, "gc")); GCInfoBuffer = CreateBuffer(sys_allocator, GetUniqueBufferName(ProjectDirectory, "gc"));
GCInfoBuffer->special = true; GCInfoBuffer->special = true;

View File

@@ -331,7 +331,7 @@ BSet Open(Window *window, String path, ResolveOpenMeta meta, bool set_active = t
Exec(set.view->id, false, o.path, GetPrimaryDirectory()); Exec(set.view->id, false, o.path, GetPrimaryDirectory());
} else if (o.kind == OpenKind_BackgroundExec) { } else if (o.kind == OpenKind_BackgroundExec) {
// this shouldn't change the focus/window/view // this shouldn't change the focus/window/view
Exec(NullViewID, false, o.path, GetPrimaryDirectory()); Exec(LogViewID, false, o.path, GetPrimaryDirectory());
} else if (o.kind == OpenKind_Command) { } else if (o.kind == OpenKind_Command) {
EvalCommand(o.path); EvalCommand(o.path);
} }

View File

@@ -76,16 +76,16 @@ bool ViewIsActive(ViewID id) {
return false; return false;
} }
API bool ViewIsReferenced(ViewID view) { API bool ViewIsReferenced(View *view) {
if (view == NullViewID) { if (view->special) {
return true; return true;
} }
if (ViewIsCrumb(view)) { if (ViewIsCrumb(view->id)) {
return true; return true;
} }
return ViewIsActive(view); return ViewIsActive(view->id);
} }
void Close(ViewID id) { void Close(ViewID id) {
@@ -110,7 +110,9 @@ String16 FetchLoadWord(View *view) {
Buffer *buffer = GetBuffer(view->active_buffer); Buffer *buffer = GetBuffer(view->active_buffer);
Caret caret = view->carets[0]; Caret caret = view->carets[0];
Range range = caret.range; Range range = caret.range;
if (GetSize(caret.range) == 0) range = EncloseLoadWord(buffer, GetFront(caret)); if (GetSize(caret.range) == 0) {
range = EncloseLoadWord(buffer, GetFront(caret));
}
String16 string = GetString(buffer, range); String16 string = GetString(buffer, range);
return string; return string;
} }