Compare commits

...

2 Commits

Author SHA1 Message Date
Krzosa Karol
a96cead179 Fix indenting 2026-01-06 14:15:20 +01:00
Krzosa Karol
73a19e2260 Try decreasing number of events, testing period 2026-01-06 13:40:45 +01:00
2 changed files with 25 additions and 16 deletions

View File

@@ -455,9 +455,17 @@ Event TranslateSDLEvent(SDL_Event *input_event) {
}
inline void AddEvent(Array<Event> *events, Event ev) {
if (ev.kind == EVENT_TEXT_INPUT && (ev.ctrl || ev.alt || ev.super)) {
bool any_special_modifiers = (ev.ctrl || ev.alt || ev.super);
if (ev.kind == EVENT_TEXT_INPUT && any_special_modifiers) {
return;
}
if (ev.kind == EVENT_KEY_PRESS && !any_special_modifiers && ev.key >= SDLK_A && ev.key <= SDLK_Z) {
if (ev.key != SDLK_RETURN) {
return;
}
}
if (ev.kind == EVENT_NONE) {
return;
}

View File

@@ -150,26 +150,24 @@ String16 GetIndentString(Allocator allocator, Int indent_size) {
char16_t *result = AllocArray(allocator, char16_t, indent_size + 1);
char16_t c = GetIndentChar();
for (int i = 0; i < IndentSize; i += 1) {
for (int i = 0; i < indent_size; i += 1) {
result[i] = c;
}
result[IndentSize] = 0;
result[indent_size] = 0;
String16 res = {result, indent_size};
return res;
}
Int FindScopeIndent(Buffer *buffer, Int pos) {
for (Int i = pos - 1; i >= 0; i -= 1) {
if (buffer->str[i] == '{' || buffer->str[i] == '[' || buffer->str[i] == '(') {
Int line = PosToLine(buffer, pos);
return GetLineIndent(buffer, line) + IndentSize;
String GetIndentString8(Allocator allocator, Int indent_size) {
char *result = AllocArray(allocator, char, indent_size + 1);
char c = (char)GetIndentChar();
for (int i = 0; i < indent_size; i += 1) {
result[i] = c;
}
if (buffer->str[i] == '}' || buffer->str[i] == ']' || buffer->str[i] == ')') {
Int line = PosToLine(buffer, pos);
return GetLineIndent(buffer, line);
}
}
return 0;
result[indent_size] = 0;
String res = {result, indent_size};
return res;
}
void IndentedNewLine(View *view) {
@@ -180,7 +178,8 @@ void IndentedNewLine(View *view) {
For(view->carets) {
Int front = GetFront(it);
Int indent = GetLineIndent(buffer, PosToLine(buffer, front));
String string = Format(scratch, "\n%S", GetIndentString(scratch, indent));
String indent_string = GetIndentString8(scratch, indent);
String string = Format(scratch, "\n%S", indent_string);
String16 string16 = ToString16(scratch, string);
AddEdit(&edits, it.range, string16);
}
@@ -604,7 +603,9 @@ Array<Edit> ReplaceEx(Allocator scratch, View *view, String16 string) {
Buffer *buffer = GetBuffer(view->active_buffer);
Array<Edit> edits = BeginEdit(scratch, buffer, view->carets);
MergeCarets(buffer, &view->carets);
For(view->carets) AddEdit(&edits, it.range, string);
For(view->carets) {
AddEdit(&edits, it.range, string);
}
EndEdit(buffer, &edits, &view->carets, KILL_SELECTION);
return edits;
}