mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-27 05:15:05 +00:00

- it's unnecessary to implement `IEnumerable` interface - we should check `IsIntersecting` before creating `InlineElement` to avoid unnecessary works suck as running `git cat-file -t <hash>` - sort whold list after all elements have been added to avoid unnecessary memmove in `Insert` Signed-off-by: leo <longshuang@msn.cn>
37 lines
823 B
C#
37 lines
823 B
C#
namespace SourceGit.Models
|
|
{
|
|
public enum InlineElementType
|
|
{
|
|
Keyword = 0,
|
|
Link,
|
|
CommitSHA,
|
|
Code,
|
|
}
|
|
|
|
public class InlineElement
|
|
{
|
|
public InlineElementType Type { get; }
|
|
public int Start { get; }
|
|
public int Length { get; }
|
|
public string Link { get; }
|
|
|
|
public InlineElement(InlineElementType type, int start, int length, string link)
|
|
{
|
|
Type = type;
|
|
Start = start;
|
|
Length = length;
|
|
Link = link;
|
|
}
|
|
|
|
public bool IsIntersecting(int start, int length)
|
|
{
|
|
if (start == Start)
|
|
return true;
|
|
|
|
if (start < Start)
|
|
return start + length > Start;
|
|
|
|
return start < Start + Length;
|
|
}
|
|
}
|
|
}
|