Skip to content

Commit b200a75

Browse files
authored
Merge pull request #343 from tomasr/develop
v4.5 release
2 parents fd0f89f + 1b951dc commit b200a75

29 files changed

+192
-70
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ packages/
55
refs/*.dll
66
*.user
77
*.suo
8+
*.GeneratedMSBuildEditorConfig.editorconfig

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# Viasfora
22

3-
A Visual Studio 2020 extension that enhances the
3+
A Visual Studio 2022 extension that enhances the
44
text editing experience!
55

66
__Official Site__: http://viasfora.com/
77

88
__Build Status__: [![Build Status](https://ci.appveyor.com/api/projects/status/u1mpx5mqkd0k39ao)](https://ci.appveyor.com/project/tomasr/viasfora/)
99

10+
Last version supporting Visual Studio 2019 and previous releases can be found
11+
[Here](https://github.com/tomasr/viasfora/releases/tag/v4.3).
12+
1013
## Rainbow Braces
1114
Colorize ()/[]/{} based on depth!<br/>
1215
![Rainbow Braces](http://viasfora.com/img/wiki/rainbow.png)
@@ -76,4 +79,4 @@ Most features include support for the following languages
7679
* Fortran
7780

7881
# Building
79-
Visual Studio 2017 is needed for building from source.
82+
Visual Studio 2022 is needed for building from source.

src/Viasfora.Core/Viasfora.Core.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,10 @@
197197
</ItemGroup>
198198
<ItemGroup>
199199
<PackageReference Include="Newtonsoft.Json">
200-
<Version>13.0.1</Version>
200+
<Version>13.0.3</Version>
201201
</PackageReference>
202202
<PackageReference Include="Microsoft.VisualStudio.Sdk">
203-
<Version>17.1.32210.191</Version>
203+
<Version>17.6.36389</Version>
204204
</PackageReference>
205205
</ItemGroup>
206206
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

src/Viasfora.Languages/BraceScanners/CBraceScanner.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ private bool ParseText(ITextChars tc, ref CharPos pos) {
4545
this.status = stString;
4646
tc.Next();
4747
this.ParseString(tc);
48+
} else if ( tc.Char() == 'u' && tc.NChar() == '8' && tc.NNChar() == '\'' ) {
49+
this.status = stString;
50+
tc.Skip(3);
51+
this.ParseCharLiteral(tc);
52+
} else if ( tc.Char() == 'u' && tc.NChar() == '8' && tc.NNChar() == '"' ) {
53+
this.status = stString;
54+
tc.Skip(3);
55+
this.ParseString(tc);
4856
} else if ( IsHexDigit(tc.Char()) && tc.NChar() == '\'' ) {
4957
// this is a C++ 14 digit separator, such as 1'000'000 or 0xFFFF'0000
5058
tc.Skip(2);

src/Viasfora.Languages/BraceScanners/CSharpBraceScanner.cs

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ private bool ParseText(ITextChars tc, ref CharPos pos) {
8585
this.parsingExpression = false;
8686
tc.Skip(3);
8787
return this.ParseInterpolatedString(tc, ref pos);
88+
} else if ( tc.Char() == '"' && tc.NChar() == '"' && tc.NNChar() == '"' ) {
89+
this.status = stString;
90+
this.multiLine = true;
91+
this.parsingExpression = false;
92+
tc.Skip(3);
93+
this.ParseRawString(tc);
8894
} else if ( tc.Char() == '"' ) {
8995
this.status = stString;
9096
tc.Next();
@@ -134,21 +140,33 @@ private void ParseString(ITextChars tc) {
134140
this.status = stText;
135141
}
136142

137-
private void ParseMultiLineString(ITextChars tc) {
143+
private void ParseRawString(ITextChars tc) {
138144
while ( !tc.AtEnd ) {
139-
if ( tc.Char() == '"' && tc.NChar() == '"' ) {
140-
// means a single embedded double quote
141-
tc.Skip(2);
142-
} else if ( tc.Char() == '"' ) {
143-
tc.Next();
144-
this.status = stText;
145-
this.multiLine = false;
146-
return;
145+
if ( tc.Char() == '"' && tc.NChar() == '"' && tc.NNChar() == '"' ) {
146+
// done
147+
tc.Skip(3);
148+
this.status = stText;
149+
return;
147150
} else {
148151
tc.Next();
149152
}
150153
}
151154
}
155+
private void ParseMultiLineString(ITextChars tc) {
156+
while ( !tc.AtEnd ) {
157+
if ( tc.Char() == '"' && tc.NChar() == '"' ) {
158+
// means a single embedded double quote
159+
tc.Skip(2);
160+
} else if ( tc.Char() == '"' ) {
161+
tc.Next();
162+
this.status = stText;
163+
this.multiLine = false;
164+
return;
165+
} else {
166+
tc.Next();
167+
}
168+
}
169+
}
152170

153171
private void ParseMultiLineComment(ITextChars tc) {
154172
while ( !tc.AtEnd ) {

src/Viasfora.Languages/Sequences/CStringScanner.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,10 @@ private bool ParseFormatSpecifier(ref StringPart result) {
5151
if ( this.text.AtEnd || this.text.Char() == '\\' ) {
5252
break;
5353
}
54-
len++;
55-
if ( Char.IsLetter(this.text.Char()) ) {
56-
this.text.Next();
54+
if ( !IsAsciiLetterOrDigit(this.text.Char()) ) {
5755
break;
5856
}
57+
len++;
5958
this.text.Next();
6059
}
6160
// if len == 1, then we found %"
@@ -65,5 +64,11 @@ private bool ParseFormatSpecifier(ref StringPart result) {
6564
result = new StringPart(start, len, StringPartType.FormatSpecifier);
6665
return true;
6766
}
67+
68+
private static bool IsAsciiLetterOrDigit(char ch) {
69+
return (ch >= 'A' && ch <= 'Z')
70+
|| (ch >= 'a' && ch <= 'z')
71+
|| (ch >= '0' && ch <= '9');
72+
}
6873
}
6974
}

src/Viasfora.Languages/Util/ITextChars.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ public interface ITextChars {
99
char Char();
1010
char NChar();
1111
char NNChar();
12+
char NNNChar();
13+
char NNNNChar();
1214
void Next();
1315
void Skip(int count);
1416
void SkipRemainder();

src/Viasfora.Languages/Util/StringChars.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ public char NNChar() {
3434
return Available(3) ? text[position+2] : EOT;
3535
}
3636

37+
public char NNNChar() {
38+
return Available(4) ? text[position+3] : EOT;
39+
}
40+
41+
public char NNNNChar() {
42+
return Available(5) ? text[position+4] : EOT;
43+
}
44+
3745
public void Next() {
3846
Skip(1);
3947
}

src/Viasfora.Languages/Viasfora.Languages.csproj

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,8 @@
1616
<IncludeAssemblyInVSIXContainer>true</IncludeAssemblyInVSIXContainer>
1717
<IncludeDebugSymbolsInVSIXContainer>false</IncludeDebugSymbolsInVSIXContainer>
1818
</PropertyGroup>
19-
<!-- This is needed to prevent forced migrations when opening the project in Vs2012 -->
20-
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '11.0' ">
21-
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
22-
</PropertyGroup>
23-
<!-- This is needed to prevent forced migrations when opening the project in Vs2013 -->
24-
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '12.0' ">
25-
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
26-
</PropertyGroup>
27-
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '14.0' ">
28-
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
29-
</PropertyGroup>
30-
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '15.0' ">
31-
<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
32-
</PropertyGroup>
33-
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '16.0' ">
34-
<MinimumVisualStudioVersion>16.0</MinimumVisualStudioVersion>
19+
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '17.0' ">
20+
<MinimumVisualStudioVersion>17.0</MinimumVisualStudioVersion>
3521
</PropertyGroup>
3622
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
3723
<Prefer32Bit>false</Prefer32Bit>

src/Viasfora.Rainbow/RainbowLines.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Microsoft.VisualStudio.Text;
99
using Microsoft.VisualStudio.Text.Classification;
1010
using Microsoft.VisualStudio.Text.Editor;
11+
using Microsoft.VisualStudio.Text.Editor.Commanding.Commands;
1112
using Microsoft.VisualStudio.Text.Formatting;
1213
using Microsoft.VisualStudio.Utilities;
1314

@@ -19,7 +20,7 @@ namespace Winterdom.Viasfora.Rainbow {
1920
public class RainbowLinesProvider : IWpfTextViewCreationListener {
2021
[Export(typeof(AdornmentLayerDefinition))]
2122
[Name(RainbowLines.LAYER)]
22-
[Order(After = PredefinedAdornmentLayers.Text)]
23+
[Order(After = PredefinedAdornmentLayers.BlockStructure)]
2324
public AdornmentLayerDefinition LinesLayer = null;
2425

2526
[Import]
@@ -259,7 +260,7 @@ private Geometry CreateVisuals(SnapshotPoint opening, SnapshotPoint closing, Sna
259260
}
260261

261262
private IList<LinePoint> MultiLineSpan(SnapshotPoint opening, SnapshotPoint closing) {
262-
var indent = CalculateLeftOfFirstChar(opening, this.view.FormattedLineSource);
263+
var indent = CalculateLeftIndent(opening, closing, this.view.FormattedLineSource);
263264
var lines = this.view.TextViewLines.GetTextViewLinesIntersectingSpan(new SnapshotSpan(opening, closing));
264265

265266
// figure out where the vertical line goes
@@ -304,8 +305,17 @@ private IList<LinePoint> MultiLineSpan(SnapshotPoint opening, SnapshotPoint clos
304305
return points;
305306
}
306307

307-
private double CalculateLeftOfFirstChar(SnapshotPoint open, IFormattedLineSource fls) {
308-
var line = open.GetContainingLine();
308+
private double CalculateLeftIndent(SnapshotPoint opening, SnapshotPoint closing, IFormattedLineSource fls) {
309+
var openLine = opening.GetContainingLine();
310+
var closeLine = closing.GetContainingLine();
311+
312+
var openIndent = CalculateLeftOfFirstChar(openLine, fls);
313+
var closeIndent = CalculateLeftOfFirstChar(closeLine, fls);
314+
315+
return Math.Min(openIndent, closeIndent);
316+
}
317+
318+
private double CalculateLeftOfFirstChar(ITextSnapshotLine line, IFormattedLineSource fls) {
309319
var x = 0d;
310320
var start = line.Start;
311321
int spacesSinceLastTab = 0;

src/Viasfora.Rainbow/RainbowToolTipPresenter.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@
99
using Winterdom.Viasfora.Design;
1010

1111
namespace Winterdom.Viasfora.Rainbow {
12+
// Commenting this out, as I am not sure it's really needed anymore,
13+
// and I can't find a way to convert the IQuickInfoSession usage
14+
// to IAsyncQuickInfoSession since there's functionality missing there
15+
/*
1216
[Export(typeof(IIntellisensePresenterProvider))]
1317
[Name("viasfora.rainbow.tooltip.presenter")]
1418
[Order(Before="Default Quick Info Presenter")]
1519
[ContentType(ContentTypes.Text)]
20+
*/
1621
public class RainbowToolTipPresenterProvider : IIntellisensePresenterProvider {
1722
[Import]
1823
public ITextEditorFactoryService EditorFactory { get; set; }

src/Viasfora.Rainbow/Viasfora.Rainbow.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@
100100
</ItemGroup>
101101
<ItemGroup>
102102
<PackageReference Include="Newtonsoft.Json">
103-
<Version>13.0.1</Version>
103+
<Version>13.0.3</Version>
104104
</PackageReference>
105105
<PackageReference Include="Microsoft.VisualStudio.Sdk">
106-
<Version>17.1.32210.191</Version>
106+
<Version>17.6.36389</Version>
107107
</PackageReference>
108108
</ItemGroup>
109109
<ItemGroup>

src/Viasfora.Settings/Viasfora.Settings.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</ItemGroup>
3131
<ItemGroup>
3232
<PackageReference Include="Newtonsoft.Json">
33-
<Version>13.0.1</Version>
33+
<Version>13.0.3</Version>
3434
</PackageReference>
3535
</ItemGroup>
3636
<ItemGroup>

src/Viasfora.Xml/Viasfora.Xml.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
</ItemGroup>
4646
<ItemGroup>
4747
<PackageReference Include="Microsoft.VisualStudio.Sdk">
48-
<Version>17.1.32210.191</Version>
48+
<Version>17.6.36389</Version>
4949
</PackageReference>
5050
</ItemGroup>
5151
<ItemGroup>

src/Viasfora.Xml/XmlConstants.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ public static class XmlConstants {
1313
public const String XML_PREFIX = "viasfora.xml.prefix";
1414
public const String XML_CLOSING_PREFIX = "viasfora.xml.closing.prefix";
1515
public const String RAZOR_CLOSING = "viasfora.razor.closing.element";
16+
17+
// VS2022 Editors
18+
public const String CT_WEBFORMS = "WebForms";
19+
public const String CT_RAZOR = "Razor";
20+
1621
// I'd prefer "XML Delimiter" here, but no way to
1722
// use it effectively.
1823
public const String DELIMITER = PredefinedClassificationTypeNames.Operator;

src/Viasfora.Xml/XmlQuickInfoController.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Threading.Tasks;
34
using Microsoft.VisualStudio.Language.Intellisense;
45
using Microsoft.VisualStudio.Text;
56
using Microsoft.VisualStudio.Text.Editor;
@@ -8,7 +9,6 @@ namespace Winterdom.Viasfora.Xml {
89
internal class XmlQuickInfoController : IIntellisenseController {
910
private ITextView textView;
1011
private IList<ITextBuffer> textBuffers;
11-
private IQuickInfoSession session;
1212
private XmlQuickInfoControllerProvider provider;
1313

1414
internal XmlQuickInfoController(
@@ -44,9 +44,11 @@ void OnTextViewMouseHover(object sender, MouseHoverEventArgs e) {
4444
ITrackingPoint triggerPoint = point.Value.Snapshot.CreateTrackingPoint(
4545
point.Value.Position, PointTrackingMode.Positive);
4646
if ( this.provider.QuickInfoBroker.IsQuickInfoActive(this.textView) ) {
47-
this.session = this.provider.QuickInfoBroker.TriggerQuickInfo(this.textView, triggerPoint, true);
47+
Task task = this.provider.QuickInfoBroker.TriggerQuickInfoAsync(this.textView, triggerPoint);
48+
// Can't wait until it's done. Just let it happen Async
4849
}
4950
}
5051
}
5152
}
53+
5254
}

src/Viasfora.Xml/XmlQuickInfoControllerProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Winterdom.Viasfora.Xml {
1313
[ContentType(XmlConstants.CT_XAML)]
1414
internal class XmlQuickInfoControllerProvider : IIntellisenseControllerProvider {
1515
[Import]
16-
internal IQuickInfoBroker QuickInfoBroker { get; set; }
16+
internal IAsyncQuickInfoBroker QuickInfoBroker { get; set; }
1717

1818
public IIntellisenseController TryCreateIntellisenseController(
1919
ITextView textView, IList<ITextBuffer> subjectBuffers) {

src/Viasfora.Xml/XmlTagger.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ public IEnumerable<ITagSpan<ClassificationTag>> GetTags(NormalizedSnapshotSpanCo
5656
this.language = this.language ?? new XamlMarkup();
5757
return DoXAMLorHTML(spans);
5858
} else if ( fileType.IsOfType(XmlConstants.CT_HTML)
59-
|| fileType.IsOfType(XmlConstants.CT_HTMLX) ) {
59+
|| fileType.IsOfType(XmlConstants.CT_HTMLX)
60+
|| fileType.IsOfType(XmlConstants.CT_RAZOR)
61+
|| fileType.IsOfType(XmlConstants.CT_WEBFORMS) ) {
6062
this.language = this.language ?? new HtmlMarkup();
6163
return DoXAMLorHTML(spans);
6264
}

src/Viasfora.Xml/XmlTaggerProvider.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ namespace Winterdom.Viasfora.Xml {
1212
[ContentType(XmlConstants.CT_XAML)]
1313
[ContentType(XmlConstants.CT_HTML)]
1414
[ContentType(XmlConstants.CT_HTMLX)]
15+
[ContentType(XmlConstants.CT_WEBFORMS)]
16+
[ContentType(XmlConstants.CT_RAZOR)]
1517
[TagType(typeof(ClassificationTag))]
1618
public class XmlTaggerProvider : IViewTaggerProvider {
1719
[Import]

src/Viasfora/Viasfora.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,13 @@
261261
</ItemGroup>
262262
<ItemGroup>
263263
<PackageReference Include="Newtonsoft.Json">
264-
<Version>13.0.1</Version>
264+
<Version>13.0.3</Version>
265265
</PackageReference>
266266
<PackageReference Include="Microsoft.VisualStudio.Sdk">
267-
<Version>17.1.32210.191</Version>
267+
<Version>17.6.36389</Version>
268268
</PackageReference>
269269
<PackageReference Include="Microsoft.VSSDK.BuildTools">
270-
<Version>17.0.5232</Version>
270+
<Version>17.3.2094</Version>
271271
</PackageReference>
272272
</ItemGroup>
273273
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

src/Viasfora/source.extension.vsixmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
55
<Metadata>
66
<Identity Id="Winterdom.Viasfora.f7a33795-2b40-4125-856c-89b0bd8cd5ab"
7-
Version="4.4"
7+
Version="4.5"
88
Language="en-US"
99
Publisher="Tomas Restrepo" />
1010
<DisplayName>Viasfora</DisplayName>

tests/Viasfora.Tests/BraceScanners/CBraceScannerTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,20 @@ public void CanExtractBracesFollowingCpp14QuoteInHexLiteral() {
4040
var chars = Extract(extractor, input.Trim(), 0, 0);
4141
Assert.Equal(4, chars.Count);
4242
}
43+
[Fact]
44+
public void CanExtractBracesFollowingUtf8LiteralChar() {
45+
String input = @"x = (u8' ')";
46+
var extractor = new CBraceScanner();
47+
var chars = Extract(extractor, input.Trim(), 0, 0);
48+
Assert.Equal(2, chars.Count);
49+
}
50+
[Fact]
51+
public void CanExtractBracesFollowingUtf8LiteralString() {
52+
String input = "x = (u8\" \")";
53+
var extractor = new CBraceScanner();
54+
var chars = Extract(extractor, input.Trim(), 0, 0);
55+
Assert.Equal(2, chars.Count);
56+
}
4357
[Fact]
4458
public void CanExtractBracesFollowingCpp14QuoteInIntLiteralHex() {
4559
String input = @"if ( x == 0x80'00 ) { }";

0 commit comments

Comments
 (0)