Skip to content

Commit

Permalink
Add a property to return the number of lines in TextLines
Browse files Browse the repository at this point in the history
  • Loading branch information
Kapil Borle committed Jun 16, 2017
1 parent d796058 commit a1ec516
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Engine/EditableText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public class EditableText
{
private TextLines lines { get; set; }

/// <summary>
/// Return the number of lines in the text.
/// </summary>
public int LineCount => lines.Count;

/// <summary>
/// The text that is available for editing.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions Engine/ScriptAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1569,7 +1569,7 @@ public EditableText Fix(EditableText text, Range range, out Range updatedRange)
}

range = isRangeNull ? null : SnapToEdges(text, range);
var previousLineCount = text.Lines.Length;
var previousLineCount = text.LineCount;
var previousUnusedCorrections = 0;
do
{
Expand Down Expand Up @@ -1600,7 +1600,7 @@ public EditableText Fix(EditableText text, Range range, out Range updatedRange)
previousUnusedCorrections = unusedCorrections;

// todo add a TextLines.NumLines property because accessing TextLines.Lines is expensive
var lineCount = text.Lines.Length;
var lineCount = text.LineCount;
if (!isRangeNull && lineCount != previousLineCount)
{
range = new Range(
Expand Down

0 comments on commit a1ec516

Please sign in to comment.