private ColumnAndOffset GetColumnNumberOfFirstEquals(TextSnapshotLine line) { String snapshot = line.Text; int tabSize = Globals.MainForm.Settings.TabWidth; int column = 0; int nonWhiteSpaceCount = 0; for (int i = 0; i < line.Length; i++) { char ch = snapshot[i]; if (ch == '=') { if (isComment(line.Position + i)) { return(new ColumnAndOffset(1, i - nonWhiteSpaceCount)); } else { return(new ColumnAndOffset(column, i - nonWhiteSpaceCount)); } } // For the sake of associating characters with the '=', include only if (!CharAssociatesWithEquals(ch)) { nonWhiteSpaceCount = 0; } else { nonWhiteSpaceCount++; } if (ch == '\t') { column += tabSize - (column % tabSize); } else { column++; } // Also, check to see if this is a surrogate pair. If so, skip the next character by incrementing // the loop counter and increment the nonWhiteSpaceCount without incrementing the column // count. if (char.IsHighSurrogate(ch) && i < line.Length - 1 && char.IsLowSurrogate(snapshot[i + 1])) { nonWhiteSpaceCount++; i++; } } return(new ColumnAndOffset(-1, -1)); }
private ColumnAndOffset GetColumnNumberOfFirstEquals(TextSnapshotLine line) { String snapshot = line.Text; int tabSize = Globals.MainForm.Settings.TabWidth; int column = 0; int nonWhiteSpaceCount = 0; for (int i = 0; i < line.Length; i++) { char ch = snapshot[i]; if (ch == '=') { if (isComment(line.Position + i)) { return new ColumnAndOffset(1, i - nonWhiteSpaceCount); } else { return new ColumnAndOffset(column, i - nonWhiteSpaceCount); } } // For the sake of associating characters with the '=', include only if (!CharAssociatesWithEquals(ch)) nonWhiteSpaceCount = 0; else nonWhiteSpaceCount++; if (ch == '\t') column += tabSize - (column % tabSize); else column++; // Also, check to see if this is a surrogate pair. If so, skip the next character by incrementing // the loop counter and increment the nonWhiteSpaceCount without incrementing the column // count. if (char.IsHighSurrogate(ch) && i < line.Length - 1 && char.IsLowSurrogate(snapshot[i + 1])) { nonWhiteSpaceCount++; i++; } } return new ColumnAndOffset(-1, -1); }