Skip to content

Commit e4236eb

Browse files
committed
Comment outline (never overlap)
1 parent c7010a7 commit e4236eb

7 files changed

Lines changed: 62 additions & 12 deletions

File tree

IronScheme.VisualStudio/AsyncTokenQuickInfoSource.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class AsyncTokenQuickInfoSourceProvider : IAsyncQuickInfoSourceProvider
2222
public IAsyncQuickInfoSource TryCreateQuickInfoSource(ITextBuffer textBuffer)
2323
{
2424
return textBuffer.Properties.GetOrCreateSingletonProperty(
25-
() => new AsyncTokenQuickInfoSource(textBuffer, aggService.CreateTagAggregator<SchemeTag>(textBuffer)));
25+
() => new AsyncTokenQuickInfoSource(textBuffer,
26+
aggService.CreateTagAggregator<SchemeTag>(textBuffer)));
2627
}
2728
}
2829

@@ -82,7 +83,7 @@ public Task<QuickInfoItem> GetQuickInfoItemAsync(IAsyncQuickInfoSession session,
8283
}
8384
}
8485
}
85-
}
86+
}
8687

8788
return Task.FromResult<QuickInfoItem>(null);
8889
}

IronScheme.VisualStudio/ClassificationTagger.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ internal ClassificationTagger(ITextView view, ITextBuffer buffer, IBufferTagAggr
120120
options.SetOptionValue(DefaultOptions.ConvertTabsToSpacesOptionId, true);
121121
options.SetOptionValue(DefaultOptions.IndentSizeOptionId, 2);
122122
options.SetOptionValue(DefaultOptions.TabSizeOptionId, 2);
123+
options.SetOptionValue(DefaultOptions.TrimTrailingWhiteSpaceOptionId, true);
124+
123125
options.SetOptionValue(DefaultTextViewHostOptions.LineNumberMarginId, true);
124126

125127
_aggregator = aggregatorFactory.CreateTagAggregator<SchemeTag>(buffer);
@@ -171,8 +173,7 @@ public IEnumerable<ITagSpan<ClassificationTag>> GetTags(NormalizedSnapshotSpanCo
171173
if (tagSpan.Tag.type == Tokens.SYMBOL)
172174
{
173175
var text = tagSpans.GetText();
174-
BindingType val;
175-
if (bindings.TryGetValue(text, out val))
176+
if (bindings.TryGetValue(text, out var val))
176177
{
177178
switch ((val & ~BindingType.LocalMask))
178179
{

IronScheme.VisualStudio/Errors/ErrorTagger.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public IEnumerable<ITagSpan<ErrorTag>> GetTags(NormalizedSnapshotSpanCollection
6666
{
6767
syntax_error = null;
6868
}
69-
else if (syntax_error.Span.OverlapsWith(spans[0]))
69+
else if (syntax_error.Span.IntersectsWith(spans[0]))
7070
{
7171
yield return syntax_error;
7272
}
@@ -79,7 +79,7 @@ public IEnumerable<ITagSpan<ErrorTag>> GetTags(NormalizedSnapshotSpanCollection
7979
brace_errors.Clear();
8080
break;
8181
}
82-
else if (err.Span.OverlapsWith(spans[0]))
82+
else if (err.Span.IntersectsWith(spans[0]))
8383
{
8484
yield return err;
8585
}

IronScheme.VisualStudio/StructureTagger.cs

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,25 @@ namespace IronScheme.VisualStudio
1616
[TagType(typeof(StructureTag))]
1717
internal class StructureTaggerProvider : ITaggerProvider
1818
{
19+
[Import]
20+
IBufferTagAggregatorFactoryService aggService = null;
21+
1922
public ITagger<T> CreateTagger<T>(ITextBuffer buffer) where T : ITag
2023
{
2124
return buffer.Properties.GetOrCreateSingletonProperty(
22-
() => new StructureTagger(buffer) as ITagger<T>);
25+
() => new StructureTagger(buffer, aggService.CreateTagAggregator<SchemeTag>(buffer)) as ITagger<T>);
2326
}
2427
}
2528

2629
class StructureTagger : BaseTagger, ITagger<StructureTag>, IDisposable
2730
{
2831
private ITextBuffer buffer;
32+
private readonly ITagAggregator<SchemeTag> tagAggregator;
2933

30-
public StructureTagger(ITextBuffer buffer)
34+
public StructureTagger(ITextBuffer buffer, ITagAggregator<SchemeTag> tagAggregator)
3135
{
3236
this.buffer = buffer;
37+
this.tagAggregator = tagAggregator;
3338
}
3439

3540
IEnumerable<ITagSpan<StructureTag>> GetTags(Cons c, NormalizedSnapshotSpanCollection spans)
@@ -71,7 +76,7 @@ IEnumerable<ITagSpan<StructureTag>> GetTags(Annotation a, NormalizedSnapshotSpan
7176
var collapseHint = new SnapshotSpan(startLine.Start, endLine.End).GetText();
7277
collapseHint = new string(' ', startOffset) + collapseHint.Substring(startOffset, collapseHint.Length - startOffset - endOffset) + new string(' ', endOffset);
7378

74-
yield return new TagSpan<StructureTag>(span,
79+
yield return new TagSpan<StructureTag>(span,
7580
new StructureTag(buffer.CurrentSnapshot, span, headerSpan, type: PredefinedStructureTagTypes.Expression, isCollapsible: true, collapsedForm: header, collapsedHintForm: collapseHint));
7681

7782
if (a.expression is Cons cc)
@@ -105,6 +110,49 @@ public IEnumerable<ITagSpan<StructureTag>> GetTags(NormalizedSnapshotSpanCollect
105110
}
106111
}
107112
}
113+
114+
var lines = 0;
115+
IMappingTagSpan<SchemeTag> start = null, last = null;
116+
117+
foreach (var tag in this.tagAggregator.GetTags(new SnapshotSpan(buffer.CurrentSnapshot, 0, buffer.CurrentSnapshot.Length)))
118+
{
119+
if (tag.Tag.type == Compiler.Tokens.COMMENT)
120+
{
121+
if (start == null)
122+
{
123+
start = tag;
124+
}
125+
lines++;
126+
last = tag;
127+
continue;
128+
}
129+
130+
if (start != null)
131+
{
132+
if (lines > 2)
133+
{
134+
var ss = start.Span.GetSpans(buffer).First();
135+
var tt = last.Span.GetSpans(buffer).First();
136+
var cc = new SnapshotSpan(ss.Start, tt.End);
137+
138+
lines = 0;
139+
140+
if (spans.IntersectsWith(cc))
141+
{
142+
143+
var header = ss.Start.GetContainingLine();
144+
var headerText = header.GetText();
145+
var headerSpan = new SnapshotSpan(ss.Start, header.End);
146+
147+
yield return new TagSpan<StructureTag>(cc,
148+
new StructureTag(buffer.CurrentSnapshot, cc, headerSpan, type: PredefinedStructureTagTypes.Comment, isCollapsible: true, collapsedForm: headerText, collapsedHintForm: cc.GetText()));
149+
}
150+
}
151+
152+
start = null;
153+
last = tag;
154+
}
155+
}
108156
}
109157
}
110158
}

IronScheme.VisualStudio/source.extension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ internal sealed partial class Vsix
1111
public const string Name = "IronScheme.VisualStudio";
1212
public const string Description = @"IronScheme editor extensions for Visual Studio";
1313
public const string Language = "en-US";
14-
public const string Version = "1.999.0.48";
14+
public const string Version = "1.999.0.49";
1515
public const string Author = "leppie";
1616
public const string Tags = "ironscheme";
1717
}

IronScheme.VisualStudio/source.extension.vsixmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
33
<Metadata>
4-
<Identity Id="IronScheme.VisualStudio.19d3eb0d-b002-44a4-87f2-7d5f5b55c135" Version="1.999.0.48" Language="en-US" Publisher="leppie" />
4+
<Identity Id="IronScheme.VisualStudio.19d3eb0d-b002-44a4-87f2-7d5f5b55c135" Version="1.999.0.49" Language="en-US" Publisher="leppie" />
55
<DisplayName>IronScheme.VisualStudio</DisplayName>
66
<Description xml:space="preserve">IronScheme editor extensions for Visual Studio</Description>
77
<MoreInfo>https://github.com/IronScheme/IronScheme.VisualStudio2</MoreInfo>

IronScheme.VisualStudio/visualstudio.sls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; License
2-
; Copyright (c) 2007-2016 Llewellyn Pritchard
2+
; Copyright (c) 2016-2021 Llewellyn Pritchard
33
; All rights reserved.
44
; This source code is subject to terms and conditions of the BSD License.
55

0 commit comments

Comments
 (0)