Skip to content

Commit ef4afdd

Browse files
committed
add known issue
1 parent b57a10c commit ef4afdd

File tree

1 file changed

+147
-0
lines changed

1 file changed

+147
-0
lines changed

KNOWN_ISSUES.md

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# Known Issues
2+
3+
This document tracks known limitations and issues in Splitmark that are documented but not yet resolved.
4+
5+
## Text Selection on Wrapped Lines
6+
7+
**Status**: Known Limitation
8+
**Severity**: Minor (visual only)
9+
**Affects**: Text selection when lines wrap due to narrow terminal width
10+
11+
### Description
12+
13+
When editing long lines that wrap to multiple visual lines, text selection behavior appears inconsistent. The selection highlighting may not align correctly with the visual line breaks.
14+
15+
### Root Cause
16+
17+
- Text wrapping is **visual only** - one logical line splits into multiple display lines
18+
- Selection state tracks **logical positions** (line number + column in unwrapped text)
19+
- Rendering maps logical selection to visual lines, but doesn't account for wrap positions
20+
21+
### Example
22+
23+
```
24+
Logical line: "This is a very long line that wraps to multiple visual lines in the terminal"
25+
Visual lines:
26+
Line 1: "This is a very long line"
27+
Line 2: "that wraps to multiple"
28+
Line 3: "visual lines in the terminal"
29+
30+
Selection from char 20-40 spans visual lines 1-2 but selection rendering assumes single line.
31+
```
32+
33+
### Reproduction
34+
35+
1. Make terminal narrow (e.g., 80 columns)
36+
2. Type a long line (100+ characters)
37+
3. Use Shift+Arrow to select across the wrap point
38+
4. Selection highlighting doesn't align with visual line breaks
39+
40+
### Impact
41+
42+
**Low Impact** because:
43+
44+
- Selection **functionally works** (correct text is selected/deleted)
45+
- Only affects **visual highlighting** appearance
46+
- Rare in typical use (most Markdown lines are < 80 chars)
47+
- Workaround: Widen terminal or add manual line breaks
48+
49+
### Workaround
50+
51+
**For users:**
52+
53+
1. Use wider terminal window to avoid wrapping
54+
2. Add manual line breaks in Markdown (recommended Markdown style anyway)
55+
3. Selection still works correctly even if highlighting looks off
56+
57+
**For developers:**
58+
None currently - this is architectural limitation.
59+
60+
### Proper Fix (Future)
61+
62+
A complete fix would require:
63+
64+
1. **Logical-to-Visual mapping**
65+
66+
```javascript
67+
// Map logical position to visual position
68+
function logicalToVisual(line, col, wrapWidth) {
69+
const wrapped = wrapTextLine(line, wrapWidth);
70+
let currentPos = 0;
71+
for (let i = 0; i < wrapped.length; i++) {
72+
if (col <= currentPos + wrapped[i].length) {
73+
return {
74+
visualLine: i,
75+
visualCol: col - currentPos,
76+
};
77+
}
78+
currentPos += wrapped[i].length;
79+
}
80+
}
81+
```
82+
83+
2. **Selection rendering per visual line**
84+
85+
- Calculate selection start/end for each wrapped line segment
86+
- Apply highlighting only to the relevant portion of each visual line
87+
88+
3. **Cursor position tracking**
89+
- Track both logical position (for editing) and visual position (for display)
90+
- Update visual position when wrapping changes
91+
92+
### Complexity
93+
94+
**High complexity** (~40 hours of work):
95+
96+
- Requires refactoring TextBuffer rendering logic
97+
- Need comprehensive test coverage for edge cases
98+
- Must handle dynamic wrapping (terminal resize)
99+
- Risk of introducing new bugs in core editing
100+
101+
### Priority
102+
103+
**Low Priority** because:
104+
105+
- ✅ Functionality is not affected (correct text is selected)
106+
- ✅ Rare edge case (most lines don't wrap)
107+
- ✅ Easy workaround available (widen terminal)
108+
- ✅ No data loss or corruption risk
109+
110+
### Related Code
111+
112+
- `src/components/TextBuffer.jsx` - `renderLineWithCursorAndSelection()`
113+
- `src/components/TextBuffer.jsx` - `wrapTextLine()`
114+
- Selection state management in TextBuffer component
115+
116+
### Testing
117+
118+
Current tests do not cover wrapped line selection because it's a visual-only issue:
119+
120+
- Unit tests pass (selection logic is correct)
121+
- Integration tests pass (text operations work correctly)
122+
- Visual regression would require screenshot tests
123+
124+
---
125+
126+
## Other Known Issues
127+
128+
### None Currently
129+
130+
All other known issues have been resolved.
131+
132+
---
133+
134+
## Reporting New Issues
135+
136+
If you discover a new issue:
137+
138+
1. Check if it's already listed here
139+
2. Try to reproduce it reliably
140+
3. Open an issue on GitHub with:
141+
- Steps to reproduce
142+
- Expected behavior
143+
- Actual behavior
144+
- Environment (OS, terminal, Node.js version)
145+
- Screenshots if visual issue
146+
147+
**GitHub Issues**: https://github.com/splitmark/splitmark/issues

0 commit comments

Comments
 (0)