Try to fix the indenting again
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
#define BUFFER_DEBUG DEBUG_BUILD
|
||||
|
||||
API bool AreEqual(XY a, XY b) {
|
||||
bool result = a.x == b.x && a.y == b.y;
|
||||
return result;
|
||||
}
|
||||
|
||||
API Range MakeRange(Int a, Int b) {
|
||||
Range result = {Min(a, b), Max(a, b)};
|
||||
return result;
|
||||
|
||||
@@ -10,8 +10,6 @@ union XY {
|
||||
struct {Int col; Int line;};
|
||||
struct {Int x; Int y; };
|
||||
};
|
||||
struct XYPair { XY front; XY back; };
|
||||
|
||||
|
||||
typedef void Function();
|
||||
|
||||
|
||||
@@ -401,6 +401,7 @@ void MoveCaretsLine(View *view, int direction) {
|
||||
|
||||
// Save caret positions to fix them at end to the expected incremented by one positions
|
||||
// :PreserveXYCarets (kind of)
|
||||
struct XYPair { XY front; XY back; };
|
||||
Array<XYPair> saved_xy = {scratch};
|
||||
For (view->carets) {
|
||||
Add(&saved_xy, {PosToXY(buffer, GetFront(it)), PosToXY(buffer, GetBack(it))});
|
||||
@@ -563,16 +564,24 @@ void IndentSelectedLines(View *view, bool shift = false) {
|
||||
MergeCarets(buffer, &view->carets);
|
||||
|
||||
// :PreserveXYCarets - maybe make it as one of the strategies of adjusting carets?
|
||||
struct XYPair { XY front; XY back; };
|
||||
Array<XYPair> saved_xy = {scratch};
|
||||
For (view->carets) Add(&saved_xy, {PosToXY(buffer, GetFront(it)), PosToXY(buffer, GetBack(it))});
|
||||
|
||||
Array<Int> not_allowed_to_be_skipped_list = {scratch};
|
||||
For (view->carets) {
|
||||
if (GetSize(it.range) == 0) {
|
||||
Add(¬_allowed_to_be_skipped_list, PosToLine(buffer, it.range.min));
|
||||
}
|
||||
}
|
||||
|
||||
Array<Range> line_ranges_to_indent = GetSelectedLinesSortedExclusive(scratch, view);
|
||||
For (line_ranges_to_indent) {
|
||||
for (Int i = it.min; i < it.max; i += 1) {
|
||||
Range pos_range_of_line = GetLineRange(buffer, i);
|
||||
String16 string = GetString(buffer, pos_range_of_line);
|
||||
String16 without_whitespace = Trim(string);
|
||||
if (without_whitespace.len == 0) {
|
||||
String16 without_whitespace = GetString(buffer, GetLineRangeWithoutNL(buffer, i));
|
||||
if (without_whitespace.len == 0 && !Contains(not_allowed_to_be_skipped_list, i)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -595,6 +604,8 @@ void IndentSelectedLines(View *view, bool shift = false) {
|
||||
for (Int i = 0; i < saved_xy.len; i += 1) {
|
||||
Caret &caret = view->carets[i];
|
||||
XYPair &xypair = saved_xy[i];
|
||||
xypair.front.x += IndentSize;
|
||||
xypair.back.x += IndentSize;
|
||||
Int front = XYToPos(buffer, xypair.front);
|
||||
Int back = XYToPos(buffer, xypair.back);
|
||||
caret = MakeCaret(front, back);
|
||||
|
||||
Reference in New Issue
Block a user