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

[NBug] 0 <= offset < 9631. Parameter name: offset. #7784

Closed
JimmyZJX opened this issue Feb 17, 2020 · 3 comments · Fixed by #8250
Closed

[NBug] 0 <= offset < 9631. Parameter name: offset. #7784

JimmyZJX opened this issue Feb 17, 2020 · 3 comments · Fixed by #8250

Comments

@JimmyZJX
Copy link

Current behaviour

I simply navigate and search between files in a previous commit (File tree). A new search "Find next" give me this error.

Expected behaviour

Search the text (highlight text and jump to the location)

Steps to reproduce

I don't know how to reproduce now. Previous searches work fine.

Error Details

System.ArgumentOutOfRangeException: 0 <= offset < 9631
Parameter name: offset
Actual value was 75480.
   at ICSharpCode.TextEditor.Document.GapTextBufferStrategy.GetCharAt(Int32 offset)
   at GitUI.TextEditorSearcher.FindNextIn(Int32 offset1, Int32 offset2, Boolean searchBackward)
   at GitUI.TextEditorSearcher.FindNext(Int32 beginAtOffset, Boolean searchBackward, Boolean& loopedAround)
   at GitUI.FindAndReplaceForm.<FindNextAsync>d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at GitUI.FindAndReplaceForm.<btnFindNext_Click>d__26.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

Additional information

I simply navigate and search between files in a previous commit (File tree). A new search "Find next" give me this error.

Environment

  • Git Extensions 3.3.1.7897
  • Build 5a97671
  • Git 2.19.1.windows.1 (recommended: 2.23.0 or later)
  • Microsoft Windows NT 10.0.17763.0
  • .NET Framework 4.8.4075.0
  • DPI 96dpi (no scaling)
@skulwicki
Copy link

I also ran into this bug today. It specifically happens on Find (selection only) operations.
Steps to reproduce:

  1. Select at least two lines from the file diff view.
  2. Open the find window (should now say selection only).
  3. Search for some text that is not in the selection that was made in step 1. The application will then crash.

Note: The application only crashes when doing a find next/previous. Find all and highlight does not cause a crash.

@gerhardol
Copy link
Member

Reproduced

@gerhardol gerhardol added the up-for-grabs Easy tasks for those looking to get involved. Refer to https://up-for-grabs.net/ label Feb 17, 2020
@realkompot
Copy link
Contributor

This is specific to "selection only" searches. Steps to reproduce when working with File tree:

  1. Select a file in the file tree.
  2. Select some text and open the find window (should say "selection only").
  3. Select another file (without closing the Find window) so that the file viewer on the right displays it.
  4. Press "Find next" in the Find window.

I could also reproduce the bug in File history view.

Cause:

FindAndReplaceForm uses TextMarker to represent the region to scan when searching. Looks like it was chosen because it reacts to changes to the document and adjusts accordingly.
I believe this was needed to properly implement "replace in selected region" functionality because the replacement string can have different length.
The problem is when a completely new text is assigned to the viewer control - the underlying ICSharpCode.TextEditor is not able correctly update TextMarkers and they go out of document's range and the subsequent search crashes.
It was easier to reproduce in the diff view because there FindAndReplaceForm searches multiple files and in the process "orders" Diff view to switch between them (assign new text to the viewer).

Possible fix: Discard "selection only" search mode when the viewer needs to show another file.

@ghost ghost added the 🚧 status: in progress Issues which have associated PRs label Jun 19, 2020
@ghost ghost removed the 🚧 status: in progress Issues which have associated PRs label Jun 24, 2020
@RussKie RussKie removed the up-for-grabs Easy tasks for those looking to get involved. Refer to https://up-for-grabs.net/ label Jun 24, 2020
RussKie pushed a commit to RussKie/gitextensions that referenced this issue Jul 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants