This commit is contained in:
Krzosa Karol
2024-08-13 10:43:47 +02:00
parent 9cac98d961
commit 26c1180fad
3 changed files with 12 additions and 9 deletions

View File

@@ -21,6 +21,12 @@ String16 GetString(Buffer *buffer, Range range = {0, INT64_MAX}) {
return result;
}
String AllocCharString(Allocator allocator, Buffer *buffer, Range range = {0, INT64_MAX}) {
String16 string16 = GetString(buffer, range);
String result = ToString(allocator, string16);
return result;
}
Int Clamp(const Buffer *buffer, Int pos) {
Int result = Clamp(pos, (Int)0, buffer->len);
return result;

View File

@@ -384,16 +384,14 @@ void SaveBuffer(View *view) {
// {
// Scratch scratch;
// String16 string16 = GetString(buffer);
// String string = ToString(scratch, string16);
// String string = AllocCharString(scratch, buffer);
// Buffer *temp_buffer = ExecAndWait(scratch, "clang-format", GetDir(buffer), string);
// Command_ReplaceWithoutMovingCarets(view, GetRange(buffer), {temp_buffer->str, temp_buffer->len});
// }
Scratch scratch;
String16 string16 = GetString(buffer);
String string = ToString(scratch, string16);
bool success = WriteFile(buffer->name, string);
Scratch scratch;
String string = AllocCharString(scratch, buffer);
bool success = WriteFile(buffer->name, string);
if (success) {
buffer->dirty = false;

View File

@@ -300,9 +300,8 @@ void UpdateLua() {
Buffer *lua_buffer = GetBuffer(LuaBufferID);
if (lua_buffer->dirty == false && lua_buffer->change_id != LuaBufferChangeID) {
Scratch scratch;
String16 string16 = GetString(lua_buffer);
String string = ToString(scratch, string16);
Scratch scratch;
String string = AllocCharString(scratch, lua_buffer);
if (luaL_dostring(LuaState, string.data) == LUA_OK) {
if (lua_isstring(LuaState, -1)) {
const char *text = lua_tostring(LuaState, -1);