Buffer name resolution simply appends a project relative path for files inside the project and a global path for files outside.
This commit is contained in:
parent
2142ef2ce9
commit
001cf5fa57
|
@ -1,3 +1,4 @@
|
||||||
build/
|
build/
|
||||||
current_dist*/
|
current_dist*/
|
||||||
distributions/
|
distributions/
|
||||||
|
build_stable/
|
||||||
|
|
2
TODO.md
2
TODO.md
|
@ -10,11 +10,13 @@ PRIME DIRECTIVE: SIMPLIFY
|
||||||
[] Look into removing *keyboard* buffer - seems like over long sessions, that could get out of hand
|
[] Look into removing *keyboard* buffer - seems like over long sessions, that could get out of hand
|
||||||
- good first step: print out the memory footprint of this buffer when we exit 4coder, just so we can see what it's taking up
|
- good first step: print out the memory footprint of this buffer when we exit 4coder, just so we can see what it's taking up
|
||||||
[] multi cursor editing
|
[] multi cursor editing
|
||||||
|
[] matching curly brace highlight
|
||||||
|
|
||||||
## Investigations
|
## Investigations
|
||||||
[] What are fade ranges? Do we need them?
|
[] What are fade ranges? Do we need them?
|
||||||
|
|
||||||
# DONE
|
# DONE
|
||||||
|
[x] when buffers have the same filename, a short name is appended. I'd prefer to append the path relative to the project, and if the file is outside the project, append the full path.
|
||||||
[x] reload dirty files if there are no local edits to them automatically
|
[x] reload dirty files if there are no local edits to them automatically
|
||||||
[x] remove audio (search @Remove)
|
[x] remove audio (search @Remove)
|
||||||
[x] backspace through entire filename in navigation strip at top
|
[x] backspace through entire filename in navigation strip at top
|
||||||
|
|
|
@ -681,6 +681,70 @@ BUFFER_NAME_RESOLVER_SIG(default_buffer_name_resolution){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BUFFER_NAME_RESOLVER_SIG(gs_buffer_name_resolution)
|
||||||
|
{
|
||||||
|
if (conflict_count <= 1) return;
|
||||||
|
Scratch_Block scratch(app);
|
||||||
|
|
||||||
|
Variable_Handle prj_var = vars_read_key(vars_get_root(), vars_save_string_lit("prj_config"));
|
||||||
|
String8 prj_dir = prj_path_from_project(scratch, prj_var);
|
||||||
|
u8 path_divider = '\\';
|
||||||
|
u64 prj_dir_slash_index = string_find_first_slash(prj_dir);
|
||||||
|
if (prj_dir_slash_index < prj_dir.size) path_divider = prj_dir.str[prj_dir_slash_index];
|
||||||
|
|
||||||
|
for (int i = 0; i < conflict_count; i++)
|
||||||
|
{
|
||||||
|
Buffer_Name_Conflict_Entry *conflict = &conflicts[i];
|
||||||
|
String_Const_u8 file_name = conflict->file_name;
|
||||||
|
String_Const_u8 uniqueifier;
|
||||||
|
|
||||||
|
// Convert the file_name_prefix to have the same path divider as prj_dir
|
||||||
|
String_Const_u8 file_name_prefix = push_string_copy(scratch, string_prefix(file_name, prj_dir.size));
|
||||||
|
for (int j = 0; j < file_name_prefix.size; j++)
|
||||||
|
{
|
||||||
|
if (character_is_slash(file_name_prefix.str[j])) file_name_prefix.str[j] = path_divider;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the full path to the file matches the project path,
|
||||||
|
// append a project local unique identifier to the filename
|
||||||
|
// otherwise, simply add on the full path to the file
|
||||||
|
if (string_match(file_name_prefix, prj_dir))
|
||||||
|
{
|
||||||
|
String_Const_u8 file_name_minus_prj_dir = string_skip(file_name, prj_dir.size);
|
||||||
|
uniqueifier = file_name_minus_prj_dir;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uniqueifier = file_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
String_u8 builder = Su8(conflict->unique_name_in_out,
|
||||||
|
conflict->unique_name_len_in_out,
|
||||||
|
conflict->unique_name_capacity);
|
||||||
|
string_append(&builder, string_u8_litexpr(" <"));
|
||||||
|
string_append(&builder, uniqueifier);
|
||||||
|
string_append(&builder, string_u8_litexpr(">"));
|
||||||
|
conflict->unique_name_len_in_out = builder.size;
|
||||||
|
}
|
||||||
|
|
||||||
|
// double check that each previously conflicting filename is unique
|
||||||
|
// on a conflict, fall back to the full system path
|
||||||
|
for (int i = 0; i < conflict_count - 1; i++)
|
||||||
|
{
|
||||||
|
String_Const_u8 unique_name_i = SCu8(conflicts[i].unique_name_in_out, conflicts[i].unique_name_len_in_out);
|
||||||
|
for (int j = i + 1; j < conflict_count; j++)
|
||||||
|
{
|
||||||
|
String_Const_u8 unique_name_j = SCu8(conflicts[j].unique_name_in_out, conflicts[j].unique_name_len_in_out);
|
||||||
|
if (string_match(unique_name_i, unique_name_j))
|
||||||
|
{
|
||||||
|
print_message(app, string_u8_litexpr("Unable to provide a unique name for a file. Falling back to its full system path"));
|
||||||
|
Assert(conflicts[j].file_name.size <= conflicts[j].unique_name_capacity);
|
||||||
|
block_copy(conflicts[j].unique_name_in_out, conflicts[j].file_name.str, conflicts[j].file_name.size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function void
|
function void
|
||||||
parse_async__inner(Async_Context *actx, Buffer_ID buffer_id,
|
parse_async__inner(Async_Context *actx, Buffer_ID buffer_id,
|
||||||
String_Const_u8 contents, Token_Array *tokens, i32 limit_factor){
|
String_Const_u8 contents, Token_Array *tokens, i32 limit_factor){
|
||||||
|
@ -1084,7 +1148,7 @@ set_all_default_hooks(Application_Links *app){
|
||||||
set_custom_hook_memory_size(app, HookID_DeltaRule,
|
set_custom_hook_memory_size(app, HookID_DeltaRule,
|
||||||
delta_ctx_size(fixed_time_cubic_delta_memory_size));
|
delta_ctx_size(fixed_time_cubic_delta_memory_size));
|
||||||
|
|
||||||
set_custom_hook(app, HookID_BufferNameResolver, default_buffer_name_resolution);
|
set_custom_hook(app, HookID_BufferNameResolver, gs_buffer_name_resolution);
|
||||||
|
|
||||||
set_custom_hook(app, HookID_BeginBuffer, default_begin_buffer);
|
set_custom_hook(app, HookID_BeginBuffer, default_begin_buffer);
|
||||||
set_custom_hook(app, HookID_EndBuffer, end_buffer_close_jump_list);
|
set_custom_hook(app, HookID_EndBuffer, end_buffer_close_jump_list);
|
||||||
|
|
Loading…
Reference in New Issue