private void PHPAutoIndentNeeded(object sender, AutoIndentEventArgs args)
{
/*
FastColoredTextBox tb = sender as FastColoredTextBox;
tb.CalcAutoIndentShiftByCodeFolding(sender, args);*/
//block {}
if (Regex.IsMatch(args.LineText, @"^[^""']*\{.*\}[^""']*$"))
return;
//start of block {}
if (Regex.IsMatch(args.LineText, @"^[^""']*\{"))
{
args.ShiftNextLines = args.TabLength;
return;
}
//end of block {}
if (Regex.IsMatch(args.LineText, @"}[^""']*$"))
{
args.Shift = -args.TabLength;
args.ShiftNextLines = -args.TabLength;
return;
}
//is unclosed operator in previous line ?
if (Regex.IsMatch(args.PrevLineText, @"^\s*(if|for|foreach|while|[\}\s]*else)\b[^{]*$"))
if (!Regex.IsMatch(args.PrevLineText, @"(;\s*$)|(;\s*//)")) //operator is unclosed
{
args.Shift = args.TabLength;
}
}