antirez / antirez/kilo

editorDelRow increments row indices instead of decrementing them

Đang mở
#117 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C
Star
9.1k
Fork
995
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

In `editorDelRow` (line 628), after `memmove` shifts rows left to fill the gap, the loop updates row indices:

```c
for (int j = at; j < E.numrows-1; j++) E.row[j].idx++;
```

This increments `idx`, but deletion should decrement it. After deleting row 5, row 6 (now at position 5) should have `idx = 5`, not `idx = 7`.

Compare with `editorInsertRow` (line 597), which correctly increments after shifting rows right:

```c
for (int j = at+1; j <= E.numrows; j++) E.row[j].idx++;
```

The fix is `E.row[j].idx--` instead of `E.row[j].idx++`.

The corrupted `idx` values cause `editorUpdateSyntax` to access wrong rows when checking for open multi-line comments (line 408), which can lead to the segfault reported in #28. PR #20 contains a fix but was never merged.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.