question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug when using `ScrollTo()` method

See original GitHub issue

Describe the bug A bit similar to the #1866 I had previously opened.

In this case, when the ScrollTo method runs for a few lines down and you try to type something, an error is thrown.

To Reproduce Steps to reproduce the behavior: In the screenshots

Expected behavior Perhaps in this case, it would be correct for the cursor to go to the line that was defined in the parameter of the ScrollTo() method

Screenshots

  1. Before: image

  2. After pressing the Ctrl + CursorDown key, which I put as binding in the code next to the console: image

  3. I try to type anything and boom: image

Desktop (please complete the following information):

  • OS: Windows 10 21H2 - Build 19044.1826
  • Browser: Edge
  • Version: 103.0.1264.62

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13

github_iconTop GitHub Comments

2reactions
luizfernandonbcommented, Jul 21, 2022

I was waiting for a library update on NuGet to be able to test, will it take a long time to come out?

I recommend to you to have two projects, one using the NuGet package and another using the gui.cs repo. Only this way you can really test if the fixes is working. Waiting for a update package sometimes it take lo long time.

Okay, thanks, I’ll do that, if it works, I’ll close this issue.

1reaction
luizfernandonbcommented, Jul 26, 2022

This unit test proves that the CursorPosition is working by setting his value. The ScrollTo method only moves the text but without change the cursor position. After scrolling you have to click on the position you want and then typing. This is the normal ScrollTo behavior. If you want more or less a near localization of the text the LeftColumn and the TopRow gives the information about the cols and rows were scrolled and using the TextView width and height there is a approximated indicator where you are in the text. Note that the column is 100 because the cursor need an extra column in the end of the line. If you want to set to the scrolled position you can set like this: CursorPosition = new Point(LeftColumn, TopRow)

		[Fact]
		[AutoInitShutdown]
		public void MoveDown_By_Setting_CursorPosition ()
		{
			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) + (i == 99 ? "" : Environment.NewLine);

			Assert.Equal (new Point (0, 0), tv.CursorPosition);
			tv.CursorPosition = new Point (5, 50);
			Assert.Equal (new Point (5, 50), tv.CursorPosition);

			tv.CursorPosition = new Point (200, 200);
			Assert.Equal (new Point (100, 99), tv.CursorPosition);
		}

		[Fact]
		[AutoInitShutdown]
		public void ScrollTo_CursorPosition ()
		{
			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) + (i == 99 ? "" : Environment.NewLine);

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

			tv.CursorPosition = new Point (tv.LeftColumn, tv.TopRow);
			Assert.Equal (new Point (0, 50), tv.CursorPosition);
		}

Now I understand, thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JavaScript scrollTo method does nothing?
Scrolling is done window by window. If you are in a frame that can't scroll, then nothing will scroll. If you want that...
Read more >
ScrollViewProxy scrollTo will crash when scrolling outside ...
Make sure that the ScrollViewProxy object you are calling scrollTo() on is not nil. If it is nil, this could cause a crash....
Read more >
Window: scrollTo() method - Web APIs - MDN Web Docs
Window: scrollTo() method. Window.scrollTo() scrolls to a particular set of coordinates in the document. Syntax.
Read more >
Scrolling stops suddenly near bottom of page when using ...
This problem is happening in browsers in which the address bar is always visible. Tried running ScrollTrigger.refresh() on a 1 second interval ...
Read more >
Element: scrollTo() method - Web APIs - MDN Web Docs
The scrollTo() method of the Element interface scrolls to a particular set of coordinates inside a given element.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found