diff --git a/src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditDocumentAdapter.cs b/src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditDocumentAdapter.cs index d7fd0f7ba1..1c31e665ff 100644 --- a/src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditDocumentAdapter.cs +++ b/src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditDocumentAdapter.cs @@ -112,12 +112,22 @@ namespace ICSharpCode.SharpDevelop.Editor.AvalonEdit public int PositionToOffset(int line, int column) { - return document.GetOffset(new TextLocation(line, column)); + try { + return document.GetOffset(new TextLocation(line, column)); + } catch (ArgumentOutOfRangeException e) { + // for UDC: re-throw exception so that stack trace identifies the caller (instead of the adapter) + throw new ArgumentOutOfRangeException(e.ParamName, e.ActualValue, e.Message); + } } public Location OffsetToPosition(int offset) { - return ToLocation(document.GetLocation(offset)); + try { + return ToLocation(document.GetLocation(offset)); + } catch (ArgumentOutOfRangeException e) { + // for UDC: re-throw exception so that stack trace identifies the caller (instead of the adapter) + throw new ArgumentOutOfRangeException(e.ParamName, e.ActualValue, e.Message); + } } public static Location ToLocation(TextLocation position)