Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorLluis Sanchez <lluis@xamarin.com>2019-07-04 17:24:23 +0300
committerGitHub <noreply@github.com>2019-07-04 17:24:23 +0300
commit4f4478eefc9e2a4a2efac2dcdb079a9e1174c726 (patch)
tree5daa1af3f40b6d6cbc150ea6204aab2303edd0be /main
parent1e8f6693382213216faab10624e87df8281027ae (diff)
parentea34bbf4acb7ac1436e8509f68151dcf725c7619 (diff)
Merge pull request #8131 from mono/backport-pr-917028-to-release-8.2
[Backport] Fixes VSTS 917028: Calling ScrollToRequestedCaretLocation with an invalid line number caused an exception
Diffstat (limited to 'main')
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentManager.cs23
1 files changed, 18 insertions, 5 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentManager.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentManager.cs
index c01448bdb4..80a607ed29 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentManager.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentManager.cs
@@ -657,11 +657,24 @@ namespace MonoDevelop.Ide.Gui.Documents
} else {
var offset = info.Offset;
if (offset < 0) {
- var line = textView.TextSnapshot.GetLineFromLineNumber (info.Line - 1);
- if (info.Column >= 1) {
- offset = line.Start + Math.Min (info.Column - 1, line.Length);
- } else {
- offset = line.Start;
+ try {
+ if (info.Line - 1 > (textView?.TextSnapshot?.LineCount ?? 0)) {
+ LoggingService.LogInfo ($"ScrollToRequestedCaretLocation line was over the snapshot's line count. "
+ + $"Called with {info.Line - 1} but line count was {textView?.TextSnapshot?.LineCount}");
+ return;
+ }
+
+ var line = textView.TextSnapshot.GetLineFromLineNumber (info.Line - 1);
+ if (info.Column >= 1) {
+ offset = line.Start + Math.Min (info.Column - 1, line.Length);
+ } else {
+ offset = line.Start;
+ }
+ } catch (ArgumentException ae) {
+ LoggingService.LogError ($"Calling GetLineFromLineNumber resulted in an argument exception."
+ + $"We tried calling with line number: {info.Line - 1}", ae);
+ // we should just abort in this case, since we can't really do anything
+ return;
}
}
if (editorOperationsFactoryService != null) {