-
Notifications
You must be signed in to change notification settings - Fork 779
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 10 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,7 @@ private bool MoveLeft () | |
| { | ||
| CurrentColumn--; | ||
|
|
||
| if (Viewport.X > 0 && CurrentColumn <= Viewport.X) | ||
| if ((Viewport.X > 0 && CurrentColumn <= Viewport.X) || CurrentColumn >= Viewport.X + Viewport.Width) | ||
|
BDisp marked this conversation as resolved.
Outdated
|
||
| { | ||
| SetNeedsDraw (); | ||
| } | ||
|
|
@@ -296,7 +297,7 @@ private bool MoveRight () | |
| { | ||
| CurrentColumn++; | ||
|
|
||
| if (CurrentColumn >= currentLine.Count || TextModel.CursorColumn (TextModel.CellsToStringList (currentLine), CurrentColumn, TabWidth, out _, out _) >= Viewport.Width) | ||
| if (CurrentColumn >= currentLine.Count || (Viewport.X > 0 && CurrentColumn < Viewport.X) || TextModel.CursorColumn (TextModel.CellsToStringList (currentLine), CurrentColumn, TabWidth, out _, out _) >= Viewport.X + Viewport.Width) | ||
| { | ||
| SetNeedsDraw (); | ||
| } | ||
|
Comment on lines
301
to
308
|
||
|
|
@@ -355,7 +356,7 @@ private bool MoveUp () | |
|
|
||
| CurrentRow--; | ||
|
|
||
| if (CurrentRow < Viewport.Y) | ||
| if (CurrentRow < Viewport.Y || CurrentRow > Viewport.Y) | ||
|
BDisp marked this conversation as resolved.
Outdated
|
||
| { | ||
| SetNeedsDraw (); | ||
| } | ||
|
|
@@ -393,6 +394,11 @@ private bool MoveWordLeft () | |
| CurrentRow = newPos.Value.row; | ||
| } | ||
|
|
||
| if (CurrentRow < Viewport.Y || CurrentColumn < Viewport.X || CurrentColumn >= Viewport.X + Viewport.Width) | ||
| { | ||
| SetNeedsDraw (); | ||
| } | ||
|
|
||
|
BDisp marked this conversation as resolved.
Outdated
|
||
| DoNeededAction (); | ||
|
|
||
| return true; | ||
|
|
@@ -408,6 +414,11 @@ private bool MoveWordRight () | |
| CurrentRow = newPos.Value.row; | ||
| } | ||
|
|
||
| if (CurrentRow >= Viewport.Y + Viewport.Height || CurrentColumn >= Viewport.X + Viewport.Width || CurrentColumn < Viewport.X) | ||
| { | ||
| SetNeedsDraw (); | ||
| } | ||
|
|
||
|
BDisp marked this conversation as resolved.
Outdated
|
||
| 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); | ||
|
|
||
| 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).