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
diff options
context:
space:
mode:
authorVsevolod Kukol <sevoku@microsoft.com>2019-04-16 00:57:52 +0300
committerGitHub <noreply@github.com>2019-04-16 00:57:52 +0300
commit8f08a6df3db3a2659ce7df0c5128e973bdfe1d47 (patch)
tree452ae212c2b21617b6450b554edb6e97d91e94a7
parent9b958ffd3fa14c85491bf847a8c3b6ac18dd4d4f (diff)
parenta49c675b72c6848c0cda0fcc8ac07a55ae014411 (diff)
Merge pull request #575 from xamarin/backport-pr-550-to-release-8.0
[release-8.0] Fixes VSTS Bug 844252: ArgumentOutOfRangeException in
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/Mono.TextEditor/Gui/TextViewMargin.cs4
-rw-r--r--main/src/core/Mono.TextEditor.Shared/Mono.TextEditor/TextSegmentMarker.cs12
2 files changed, 9 insertions, 7 deletions
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/Mono.TextEditor/Gui/TextViewMargin.cs b/main/src/addins/MonoDevelop.SourceEditor2/Mono.TextEditor/Gui/TextViewMargin.cs
index 8318f4652e..f367f9eaa5 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/Mono.TextEditor/Gui/TextViewMargin.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/Mono.TextEditor/Gui/TextViewMargin.cs
@@ -1513,9 +1513,9 @@ namespace Mono.TextEditor
throw new ArgumentNullException (nameof (text));
if (textIndex < 0)
- throw new ArgumentOutOfRangeException (nameof (textIndex));
+ throw new ArgumentOutOfRangeException (nameof (textIndex), "should be >=0 it was " + textIndex);
if (textIndex > text.Length)
- throw new ArgumentOutOfRangeException (nameof (textIndex));
+ throw new ArgumentOutOfRangeException (nameof (textIndex), $"should be <{text.Length} it was {textIndex}");
if (textIndex < curIndex) {
unsafe {
diff --git a/main/src/core/Mono.TextEditor.Shared/Mono.TextEditor/TextSegmentMarker.cs b/main/src/core/Mono.TextEditor.Shared/Mono.TextEditor/TextSegmentMarker.cs
index 957ae2c619..ee0aa54c49 100644
--- a/main/src/core/Mono.TextEditor.Shared/Mono.TextEditor/TextSegmentMarker.cs
+++ b/main/src/core/Mono.TextEditor.Shared/Mono.TextEditor/TextSegmentMarker.cs
@@ -138,7 +138,7 @@ namespace Mono.TextEditor
void InternalDraw (int markerStart, int markerEnd, MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics, bool selected, int startOffset, int endOffset, double y, double startXPos, double endXPos)
{
- if (markerStart > markerEnd)
+ if (markerStart >= markerEnd)
return;
var layout = metrics.Layout.Layout;
double @from;
@@ -147,17 +147,19 @@ namespace Mono.TextEditor
@from = startXPos;
to = endXPos;
} else {
- int start = startOffset < markerStart ? markerStart : startOffset;
- int end = endOffset < markerEnd ? endOffset : markerEnd;
+ int start = Math.Max (startOffset, markerStart);
+ int end = Math.Min (endOffset, markerEnd);
int /*lineNr,*/ x_pos;
uint curIndex = 0;
uint byteIndex = 0;
- metrics.Layout.TranslateToUTF8Index ((uint)(start - startOffset), ref curIndex, ref byteIndex);
+ uint idx = (uint)Math.Min (Math.Max (0, start - startOffset), metrics.Layout.Text.Length - 1);
+ metrics.Layout.TranslateToUTF8Index (idx, ref curIndex, ref byteIndex);
x_pos = layout.IndexToPos (System.Math.Max (0, (int)byteIndex)).X;
@from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
- metrics.Layout.TranslateToUTF8Index ((uint)(end - startOffset), ref curIndex, ref byteIndex);
+ idx = (uint)Math.Min (Math.Max (0, end - startOffset), metrics.Layout.Text.Length - 1);
+ metrics.Layout.TranslateToUTF8Index (idx, ref curIndex, ref byteIndex);
x_pos = layout.IndexToPos (System.Math.Max (0, (int)byteIndex)).X;