Repository navigation
Expand file tree
/
Copy pathReplInput.cs
More file actions
60 lines (50 loc) · 1.86 KB
/
Copy pathReplInput.cs
File metadata and controls
60 lines (50 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Diagnostics;
using Microsoft.VisualStudio.Text;
namespace Microsoft.VisualStudio.InteractiveWindow
{
[DebuggerDisplay("{GetDebuggerDisplay()}")]
internal struct ReplSpan
{
// CustomTrackingSpan or string
public object Span { get; }
public ReplSpanKind Kind { get; }
public int LineNumber { get; }
public ReplSpan(CustomTrackingSpan span, ReplSpanKind kind, int lineNumber)
: this((object)span, kind, lineNumber)
{
Debug.Assert(!kind.IsPrompt());
}
public ReplSpan(string literal, ReplSpanKind kind, int lineNumber)
: this((object)literal, kind, lineNumber)
{
}
private ReplSpan(object span, ReplSpanKind kind, int lineNumber)
{
this.Span = span;
this.Kind = kind;
this.LineNumber = lineNumber;
}
public CustomTrackingSpan TrackingSpan => (CustomTrackingSpan)Span;
public ReplSpan WithEndTrackingMode(PointTrackingMode endTrackingMode)
{
return new ReplSpan(((CustomTrackingSpan)this.Span).WithEndTrackingMode(endTrackingMode), this.Kind, this.LineNumber);
}
public ReplSpan WithLineNumber(int lineNumber)
{
return new ReplSpan(this.Span, this.Kind, lineNumber);
}
public int Length
{
get
{
var value = Span as string;
return (value != null) ? value.Length : TrackingSpan.GetSpan(TrackingSpan.TextBuffer.CurrentSnapshot).Length;
}
}
private string GetDebuggerDisplay()
{
return $"Line {LineNumber}: {Kind} - {Span}";
}
}
}