editorDelRow increments row indices instead of decrementing them
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 55/100
Research direction
Start at editorDelRow around line 628 and compare its row-shifting loop with editorInsertRow around line 597; inspect editorUpdateSyntax around line 408 to understand the affected idx lookup. Done when deleting a row leaves subsequent row indices aligned with their positions and the reported multi-line-comment crash path no longer receives corrupted indices.
Written by the indexing model from the issue text.
Description
In editorDelRow (line 628), after memmove shifts rows left to fill the gap, the loop updates row indices:
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:
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.
- Dominant language
- C
- Stars
- 9.1k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from antirez/kilo
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
Difficulty 3/5 1-2 days Newbie friendliness 38/100
Similar issues
-
level/task module/gcp type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
hapostgres/pg_auto_failover#1190 ·
-
docs
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
P3 sonic-vpp
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
sonic-net/sonic-buildimage#29662 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 94/100
spack/spack-packages#6586 ·