Skip to content
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

Bug when scrolling text and trying to type something in a TextView #1866

Closed
luizfernandonb opened this issue Jul 20, 2022 · 1 comment
Closed

Comments

@luizfernandonb
Copy link

luizfernandonb commented Jul 20, 2022

Describe the bug
The bug occurs when you scroll to several lines beyond the mouse cursor and soon after you try to write something.

Extra: In a TextView.

To Reproduce
Steps to reproduce the behavior:

  1. Open a file in a TextView that has several lines and that you can scroll using the mouse wheel.
  2. Scroll until you don't see the cursor, which isn't much.
  3. Try typing something.
  4. See error

Expected behavior
What you typed in the first line of the console, because in theory, the cursor is to follow the mouse scroll when the text is scrolled, or when you type the text, it goes to the line that the cursor was on.

Screenshots
Open any text file:
image

Scroll down the mouse to a line where it disappears:
image

Tried typing anything on the keyboard:
image

@tznind
Copy link
Collaborator

tznind commented Jul 21, 2022

Thanks for reporting this. I can confirm that I am able to reproduce and here is a unit test for this issue:

[Fact]
[AutoInitShutdown]
public void ScrollDownTillCaretOffscreen_ThenType()
{
	var tv = new TextView {
		Width = 10,
		Height = 5
	};

	// add 100 lines of wide text to view
	for (int i = 0; i < 100; i++)
		tv.Text += new string ('x', 100) + Environment.NewLine;

	Assert.Equal (0, tv.CursorPosition.Y);
	tv.ScrollTo (50);
	Assert.Equal (0, tv.CursorPosition.Y);

	tv.ProcessKey (new KeyEvent (Key.p, new KeyModifiers ()));
}

Error is currently:

Message: 
System.ArgumentException : Height must be greater or equal to 0.

  Stack Trace: 
Rect.set_Height(Int32 value) line 51
Rect.ctor(Int32 x, Int32 y, Int32 width, Int32 height) line 251
TextView.Insert(Rune rune) line 2387
TextView.InsertText(KeyEvent kb) line 3454
TextView.ProcessKey(KeyEvent kb) line 2609
TextViewTests.ScrollDownTillCaretOffscreen_ThenType() line 5714

Normally @BDisp handles TextView changes as he is most expert with the view

BDisp added a commit to BDisp/Terminal.Gui that referenced this issue Jul 21, 2022
@tig tig closed this as completed in 57fc939 Jul 21, 2022
tig added a commit that referenced this issue Aug 1, 2022
* Fixes #1861. Border Title property is preferable than the Text.

* Fixes #1866. Bug when scrolling text and type in a TextView. (#1868)

* Some fixes for the WebConsole support. (#1865)

* Invoking NotifyStopRunState for all situations.

* Added Clicked property to support web console.

* Changing to MoveDown to stay always visible.

* Fixes #1849. Wizard as non-popup is broken (#1853)

* trying to make it work

* Fixes #1849. Wizard as non-modal doesn't work

* Fixes #1855. Window and Frame content view without the margin frame.

* Fixing layout of non-modal

* WizardSTep is now a FrameView

* Now use Modal = false to set visual style automatically

* Removed Controls as an explicit construct. Now just Add to WizardStep

Co-authored-by: BDisp <[email protected]>

* Update docs with keybindings, global key event and designer (#1869)

* Added docs on keybinding and global key event

* Added TerminalGuiDesigner to showcases/examples

* Regenerated Docs (#1870)

* Fixed cancel logic. Title now shows for non-modal. (#1871)

* Fixes #1874. API docs on github are broken. (#1875)

* Fixes #1874. API docs on github are broken.

* Rebuild with docfx 2.59.3.0 version.

* Fixes Wizard cancel logic and updates docs (#1878)

* Fixed cancel logic. Title now shows for non-modal.

* trying to fix docs

* trying to fix docs

* Fixes #1867. Use Undo and Redo commands with WordWrap enabled. (#1877)

* Updated docs; regeneraged docs (#1881)

* Added a 'Read Only' to the Editor scenario Format menu. (#1882)

* Fixes #1883. Toplevel now propogates Loaded & Ready events to child Toplevel views.

* Updated API doc theme. Added Wizard Sample

* Tweaked API docs format and content. Fixed build warnings.

* Fixes #1889. Docs broken after org move.

* Regen API docs

* Fixes readme links to API docs

* Avoiding breaking change.

* Fixes typos.

* Passing string.Empty to Title from the default constructor.

* Initializes title with string.Empty instead of null.

Co-authored-by: Tig Kindel <[email protected]>
Co-authored-by: Thomas Nind <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants