Is there some spacial (internal hidden) way to extract code which cause error or I need to do something like this
using RemObjects.Script;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
class Program
{
static string GetSymbol(PositionPair position, string code)
{
var symbol = string.Empty;
var start = position.Start;
var end = position.End;
var startLine = (start.Line - 1);
var endLine = (end.Line - 1);
var startColumn = start.Column - 1;
var endColumn = end.Column - 1;
var lines = code.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
if (startLine == endLine)
{
symbol = lines[startLine].Substring(startColumn, endColumn - startColumn - 1);
}
else
{
var text = new StringBuilder();
for (int i = startLine, l = endLine; i <= l; i++)
{
if (i == startLine)
{
text.AppendLine(lines[i].Substring(startColumn));
}
else
{
if (i == endLine)
{
text.Append(lines[i].Substring(0, endColumn - 1));
}
else
{
text.AppendLine(lines[i]);
}
}
}
symbol = text.ToString();
}
return symbol;
}