-
Notifications
You must be signed in to change notification settings - Fork 774
Fix remaining TextView issues #4987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
041cfcf
ce2ce48
6ca8e82
e9f3cd8
0f27375
8074d0f
769edb0
ce4645e
14afefc
3ca7567
2496629
f6f0164
40d4147
c336758
79c079c
2e3a3d9
5dc6b6b
97d63ff
2d304d1
daba04a
3b57826
ae4e7c7
0dbccbc
b552436
767020d
ac3dbc4
ab0ece7
cecd5b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,7 +108,7 @@ private bool MoveDown () | |
|
|
||
| CurrentRow++; | ||
|
|
||
| if (CurrentRow >= Viewport.Y + Viewport.Height) | ||
| if (CurrentRow >= Viewport.Y + Viewport.Height || CurrentRow < Viewport.Y) | ||
| { | ||
| SetNeedsDraw (); | ||
| } | ||
|
|
@@ -145,8 +145,9 @@ private bool MoveEndOfLine () | |
| List<Cell> currentLine = GetCurrentLine (); | ||
| CurrentColumn = currentLine.Count; | ||
|
|
||
| if (CurrentColumn >= Viewport.X + Viewport.Width || TextModel.CursorColumn (TextModel.CellsToStringList (currentLine), CurrentColumn, TabWidth, out _, out _) - Viewport.X >= Viewport.Width) | ||
| { | ||
| if (CurrentColumn >= Viewport.X + Viewport.Width | ||
| || TextModel.CursorColumn (TextModel.CellsToStringList (currentLine), CurrentColumn, TabWidth, out _, out _) - Viewport.X >= Viewport.Width) | ||
| { | ||
| SetNeedsDraw (); | ||
| } | ||
| DoNeededAction (); | ||
|
|
@@ -160,7 +161,10 @@ private bool MoveLeft () | |
| { | ||
| CurrentColumn--; | ||
|
|
||
| if (Viewport.X > 0 && CurrentColumn <= Viewport.X) | ||
| List<Cell> currentLine = GetCurrentLine (); | ||
| int cursorColumn = TextModel.CursorColumn (TextModel.CellsToStringList (currentLine), CurrentColumn, TabWidth, out _, out _); | ||
|
|
||
| if ((Viewport.X > 0 && cursorColumn <= Viewport.X) || cursorColumn - Viewport.X >= Viewport.Width) | ||
| { | ||
| SetNeedsDraw (); | ||
| } | ||
|
|
@@ -296,7 +300,9 @@ private bool MoveRight () | |
| { | ||
| CurrentColumn++; | ||
|
|
||
| if (CurrentColumn >= currentLine.Count || TextModel.CursorColumn (TextModel.CellsToStringList (currentLine), CurrentColumn, TabWidth, out _, out _) >= Viewport.Width) | ||
| int cursorColumn = TextModel.CursorColumn (TextModel.CellsToStringList (currentLine), CurrentColumn, TabWidth, out _, out _); | ||
|
|
||
| if (cursorColumn >= currentLine.Count || (Viewport.X > 0 && cursorColumn < Viewport.X) || cursorColumn >= Viewport.X + Viewport.Width) | ||
| { | ||
| SetNeedsDraw (); | ||
| } | ||
|
Comment on lines
301
to
308
|
||
|
|
@@ -346,16 +352,19 @@ private bool MoveTopHomeExtend () | |
|
|
||
| private bool MoveUp () | ||
| { | ||
| if (CurrentRow > 0) | ||
| if (CurrentRow > 0 || (CurrentRow == 0 && CurrentRow < Viewport.Y)) | ||
| { | ||
| if (_columnTrack == -1) | ||
| { | ||
| _columnTrack = CurrentColumn; | ||
| } | ||
|
|
||
| CurrentRow--; | ||
| if (CurrentRow > 0) | ||
| { | ||
| CurrentRow--; | ||
| } | ||
|
|
||
| if (CurrentRow < Viewport.Y) | ||
| if (CurrentRow < Viewport.Y || CurrentRow >= Viewport.Y + Viewport.Height) | ||
| { | ||
| SetNeedsDraw (); | ||
| } | ||
|
|
@@ -393,6 +402,14 @@ private bool MoveWordLeft () | |
| CurrentRow = newPos.Value.row; | ||
| } | ||
|
|
||
| List<Cell> currentLine = GetCurrentLine (); | ||
| int cursorColumn = TextModel.CursorColumn (TextModel.CellsToStringList (currentLine), CurrentColumn, TabWidth, out _, out _); | ||
|
|
||
| if (CurrentRow < Viewport.Y || cursorColumn < Viewport.X || cursorColumn >= Viewport.X + Viewport.Width) | ||
| { | ||
| SetNeedsDraw (); | ||
| } | ||
|
|
||
| DoNeededAction (); | ||
|
|
||
| return true; | ||
|
|
@@ -408,6 +425,14 @@ private bool MoveWordRight () | |
| CurrentRow = newPos.Value.row; | ||
| } | ||
|
|
||
| List<Cell> currentLine = GetCurrentLine (); | ||
| int cursorColumn = TextModel.CursorColumn (TextModel.CellsToStringList (currentLine), CurrentColumn, TabWidth, out _, out _); | ||
|
|
||
| if (CurrentRow >= Viewport.Y + Viewport.Height || cursorColumn >= Viewport.X + Viewport.Width || cursorColumn < Viewport.X) | ||
| { | ||
| SetNeedsDraw (); | ||
| } | ||
|
|
||
| DoNeededAction (); | ||
|
|
||
| return true; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -558,23 +558,19 @@ private void InsertText (Key a, Attribute? attribute = null) | |
| return; | ||
| } | ||
|
|
||
| if (Used) | ||
| { | ||
| Insert (new Cell { Grapheme = grapheme, Attribute = attribute }); | ||
| CurrentColumn++; | ||
| } | ||
| else | ||
| { | ||
| Insert (new Cell { Grapheme = grapheme, Attribute = attribute }); | ||
| CurrentColumn++; | ||
| } | ||
| UpdateContentSize (); | ||
| Insert (new Cell { Grapheme = grapheme, Attribute = attribute }); | ||
| CurrentColumn++; | ||
|
|
||
| // Text was inserted, so it's always needed to redraw and update content size if needed | ||
| SetNeedsDraw (); | ||
|
|
||
| List<Cell> line = GetCurrentLine (); | ||
| (int size, int length) dSize = TextModel.DisplaySize (line, 0, CurrentColumn, true, TabWidth); | ||
| (int size, int length) dSize = TextModel.DisplaySize (line, 0, line.Count, true, TabWidth); | ||
|
|
||
| if (dSize.size + 1 - Viewport.X >= Viewport.Width) | ||
| if (_model.ShouldInvalidateMaxWidthCache (CurrentRow, true, dSize.size)) | ||
| { | ||
| SetNeedsDraw (); | ||
| _model.InvalidateMaxWidthCache (); | ||
| UpdateContentSize (); | ||
| } | ||
|
Comment on lines
+564
to
574
|
||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ShouldInvalidateMaxWidthCache() doesn't invalidate when an edit occurs on a non-max line that becomes wider than the cached max (it only checks lines already in
_cachedMaxWidthPerLine). If callers rely on this to keep GetMaxVisibleLine() correct without forcing a full invalidation, content width can become stale. Consider also invalidating whencolumnWidth > _cachedMaxWidth(and ensure callers pass the full post-edit line width).