/// <summary> /// Calculates the 1-based line and column number position based /// on the given buffer offset. /// </summary> /// <param name="bufferOffset">The buffer offset to convert.</param> /// <returns>A new BufferPosition containing the position of the offset.</returns> public BufferPosition GetPositionAtOffset(int bufferOffset) { BufferRange bufferRange = GetRangeBetweenOffsets( bufferOffset, bufferOffset); return(bufferRange.Start); }
/// <summary> /// Compares two instances of the BufferRange class. /// </summary> /// <param name="obj">The object to which this instance will be compared.</param> /// <returns>True if the ranges are equal, false otherwise.</returns> public override bool Equals(object obj) { if (!(obj is BufferRange)) { return(false); } BufferRange other = (BufferRange)obj; return (this.Start.Equals(other.Start) && this.End.Equals(other.End)); }
internal static CompletionResults Create( ScriptFile scriptFile, CommandCompletion commandCompletion) { BufferRange replacedRange = null; // Only calculate the replacement range if there are completion results if (commandCompletion.CompletionMatches.Count > 0) { replacedRange = scriptFile.GetRangeBetweenOffsets( commandCompletion.ReplacementIndex, commandCompletion.ReplacementIndex + commandCompletion.ReplacementLength); } return(new CompletionResults { Completions = GetCompletionsArray(commandCompletion), ReplacedRange = replacedRange }); }
/// <summary> /// Creates an empty CompletionResults instance. /// </summary> public CompletionResults() { this.Completions = new CompletionDetails[0]; this.ReplacedRange = new BufferRange(0, 0, 0, 0); }
/// <summary> /// Creates an empty CompletionResults instance. /// </summary> public CompletionResults() { this.Completions = Array.Empty <CompletionDetails>(); this.ReplacedRange = new BufferRange(0, 0, 0, 0); }