Improve ctrl movement, fix delete indent bug

This commit is contained in:
Krzosa Karol
2024-08-09 10:11:19 +02:00
parent 6d9792b1a6
commit 19546eea4d
3 changed files with 10 additions and 10 deletions

View File

@@ -333,26 +333,28 @@ Int GetNextWordEnd(Buffer *buffer, Int pos) {
// too early and we cannot establish the proper range
// semantics - proper max is one past last index
if (!(i < buffer->len)) break;
if ((prev && prev != buffer->str[i]) || IsWord(buffer->str[i])) {
if (prev == L'\n' || (prev && prev != buffer->str[i]) || IsWord(buffer->str[i])) {
break;
}
prev = buffer->str[i];
}
Int result = GetWordEnd(buffer, pos);
Int result = prev == L'\n' ? pos : GetWordEnd(buffer, pos);
return result;
}
Int GetPrevWordStart(Buffer *buffer, Int pos) {
pos = Clamp(pos, (Int)0, buffer->len);
wchar_t prev = 0;
for (Int i = pos - 1; i >= 0; i -= 1) {
if ((prev && prev != buffer->str[i]) || IsWord(buffer->str[i])) {
Int i = pos - 1;
for (; i >= 0; i -= 1) {
if (prev == L'\n' || (prev && prev != buffer->str[i]) || IsWord(buffer->str[i])) {
break;
}
pos = i;
prev = buffer->str[i];
}
Int result = GetWordStart(buffer, pos);
bool new_line = prev == L'\n';
Int result = new_line ? pos : GetWordStart(buffer, pos);
return result;
}

View File

@@ -415,13 +415,13 @@ void Command_Delete(View *view, int direction, bool ctrl = false) {
// Delete indent in multiple of IndentSize
Range indent_range = GetIndentRangeAtPos(buffer, it.range.min);
if (it.range.min > indent_range.min && it.range.max <= indent_range.max) {
if (ctrl == false && it.range.min > indent_range.min && it.range.max <= indent_range.max) {
Int offset = it.range.min - indent_range.min;
Int to_delete = (offset % (StyleIndentSize));
if (to_delete == 0) to_delete = StyleIndentSize;
to_delete = Clamp(to_delete, (Int)1, StyleIndentSize);
for (Int i = 0; i < to_delete; i += 1) {
it = MoveCaret(buffer, it, direction, ctrl, SHIFT_PRESSED);
it = MoveCaret(buffer, it, direction, false, SHIFT_PRESSED);
}
} else {

View File

@@ -1,13 +1,11 @@
- Remove pointers and use ViewIDs (enable array debug while doing this)
- try using git grep for search for now, combine with fuzzy search buffer
- lua maybe try heuristic matching paths from left?
- win32: change all stack buffers to arena
- search as a command to execute which is going to be in the title bar
- search backwards
- braces enclose should be performed even if we put the mouse out of bounds!
- some split selection commands
- assign commands or lua functions to F1-F12 keys
- assign commands or lua functions to F1-F8 keys
- 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?)