Skip to content

Commit

Permalink
Merge pull request #343 from tomasr/develop
Browse files Browse the repository at this point in the history
v4.5 release
  • Loading branch information
tomasr authored Jul 4, 2023
2 parents fd0f89f + 1b951dc commit b200a75
Show file tree
Hide file tree
Showing 29 changed files with 192 additions and 70 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ packages/
refs/*.dll
*.user
*.suo
*.GeneratedMSBuildEditorConfig.editorconfig
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# Viasfora

A Visual Studio 2020 extension that enhances the
A Visual Studio 2022 extension that enhances the
text editing experience!

__Official Site__: http://viasfora.com/

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

Last version supporting Visual Studio 2019 and previous releases can be found
[Here](https://github.com/tomasr/viasfora/releases/tag/v4.3).

## Rainbow Braces
Colorize ()/[]/{} based on depth!<br/>
![Rainbow Braces](http://viasfora.com/img/wiki/rainbow.png)
Expand Down Expand Up @@ -76,4 +79,4 @@ Most features include support for the following languages
* Fortran

# Building
Visual Studio 2017 is needed for building from source.
Visual Studio 2022 is needed for building from source.
4 changes: 2 additions & 2 deletions src/Viasfora.Core/Viasfora.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json">
<Version>13.0.1</Version>
<Version>13.0.3</Version>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Sdk">
<Version>17.1.32210.191</Version>
<Version>17.6.36389</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
8 changes: 8 additions & 0 deletions src/Viasfora.Languages/BraceScanners/CBraceScanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ private bool ParseText(ITextChars tc, ref CharPos pos) {
this.status = stString;
tc.Next();
this.ParseString(tc);
} else if ( tc.Char() == 'u' && tc.NChar() == '8' && tc.NNChar() == '\'' ) {
this.status = stString;
tc.Skip(3);
this.ParseCharLiteral(tc);
} else if ( tc.Char() == 'u' && tc.NChar() == '8' && tc.NNChar() == '"' ) {
this.status = stString;
tc.Skip(3);
this.ParseString(tc);
} else if ( IsHexDigit(tc.Char()) && tc.NChar() == '\'' ) {
// this is a C++ 14 digit separator, such as 1'000'000 or 0xFFFF'0000
tc.Skip(2);
Expand Down
36 changes: 27 additions & 9 deletions src/Viasfora.Languages/BraceScanners/CSharpBraceScanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ private bool ParseText(ITextChars tc, ref CharPos pos) {
this.parsingExpression = false;
tc.Skip(3);
return this.ParseInterpolatedString(tc, ref pos);
} else if ( tc.Char() == '"' && tc.NChar() == '"' && tc.NNChar() == '"' ) {
this.status = stString;
this.multiLine = true;
this.parsingExpression = false;
tc.Skip(3);
this.ParseRawString(tc);
} else if ( tc.Char() == '"' ) {
this.status = stString;
tc.Next();
Expand Down Expand Up @@ -134,21 +140,33 @@ private void ParseString(ITextChars tc) {
this.status = stText;
}

private void ParseMultiLineString(ITextChars tc) {
private void ParseRawString(ITextChars tc) {
while ( !tc.AtEnd ) {
if ( tc.Char() == '"' && tc.NChar() == '"' ) {
// means a single embedded double quote
tc.Skip(2);
} else if ( tc.Char() == '"' ) {
tc.Next();
this.status = stText;
this.multiLine = false;
return;
if ( tc.Char() == '"' && tc.NChar() == '"' && tc.NNChar() == '"' ) {
// done
tc.Skip(3);
this.status = stText;
return;
} else {
tc.Next();
}
}
}
private void ParseMultiLineString(ITextChars tc) {
while ( !tc.AtEnd ) {
if ( tc.Char() == '"' && tc.NChar() == '"' ) {
// means a single embedded double quote
tc.Skip(2);
} else if ( tc.Char() == '"' ) {
tc.Next();
this.status = stText;
this.multiLine = false;
return;
} else {
tc.Next();
}
}
}

private void ParseMultiLineComment(ITextChars tc) {
while ( !tc.AtEnd ) {
Expand Down
11 changes: 8 additions & 3 deletions src/Viasfora.Languages/Sequences/CStringScanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,10 @@ private bool ParseFormatSpecifier(ref StringPart result) {
if ( this.text.AtEnd || this.text.Char() == '\\' ) {
break;
}
len++;
if ( Char.IsLetter(this.text.Char()) ) {
this.text.Next();
if ( !IsAsciiLetterOrDigit(this.text.Char()) ) {
break;
}
len++;
this.text.Next();
}
// if len == 1, then we found %"
Expand All @@ -65,5 +64,11 @@ private bool ParseFormatSpecifier(ref StringPart result) {
result = new StringPart(start, len, StringPartType.FormatSpecifier);
return true;
}

private static bool IsAsciiLetterOrDigit(char ch) {
return (ch >= 'A' && ch <= 'Z')
|| (ch >= 'a' && ch <= 'z')
|| (ch >= '0' && ch <= '9');
}
}
}
2 changes: 2 additions & 0 deletions src/Viasfora.Languages/Util/ITextChars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public interface ITextChars {
char Char();
char NChar();
char NNChar();
char NNNChar();
char NNNNChar();
void Next();
void Skip(int count);
void SkipRemainder();
Expand Down
8 changes: 8 additions & 0 deletions src/Viasfora.Languages/Util/StringChars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ public char NNChar() {
return Available(3) ? text[position+2] : EOT;
}

public char NNNChar() {
return Available(4) ? text[position+3] : EOT;
}

public char NNNNChar() {
return Available(5) ? text[position+4] : EOT;
}

public void Next() {
Skip(1);
}
Expand Down
18 changes: 2 additions & 16 deletions src/Viasfora.Languages/Viasfora.Languages.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,8 @@
<IncludeAssemblyInVSIXContainer>true</IncludeAssemblyInVSIXContainer>
<IncludeDebugSymbolsInVSIXContainer>false</IncludeDebugSymbolsInVSIXContainer>
</PropertyGroup>
<!-- This is needed to prevent forced migrations when opening the project in Vs2012 -->
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '11.0' ">
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
</PropertyGroup>
<!-- This is needed to prevent forced migrations when opening the project in Vs2013 -->
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '12.0' ">
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '14.0' ">
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '15.0' ">
<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '16.0' ">
<MinimumVisualStudioVersion>16.0</MinimumVisualStudioVersion>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '17.0' ">
<MinimumVisualStudioVersion>17.0</MinimumVisualStudioVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<Prefer32Bit>false</Prefer32Bit>
Expand Down
18 changes: 14 additions & 4 deletions src/Viasfora.Rainbow/RainbowLines.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Classification;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Editor.Commanding.Commands;
using Microsoft.VisualStudio.Text.Formatting;
using Microsoft.VisualStudio.Utilities;

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

[Import]
Expand Down Expand Up @@ -259,7 +260,7 @@ private Geometry CreateVisuals(SnapshotPoint opening, SnapshotPoint closing, Sna
}

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

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

private double CalculateLeftOfFirstChar(SnapshotPoint open, IFormattedLineSource fls) {
var line = open.GetContainingLine();
private double CalculateLeftIndent(SnapshotPoint opening, SnapshotPoint closing, IFormattedLineSource fls) {
var openLine = opening.GetContainingLine();
var closeLine = closing.GetContainingLine();

var openIndent = CalculateLeftOfFirstChar(openLine, fls);
var closeIndent = CalculateLeftOfFirstChar(closeLine, fls);

return Math.Min(openIndent, closeIndent);
}

private double CalculateLeftOfFirstChar(ITextSnapshotLine line, IFormattedLineSource fls) {
var x = 0d;
var start = line.Start;
int spacesSinceLastTab = 0;
Expand Down
5 changes: 5 additions & 0 deletions src/Viasfora.Rainbow/RainbowToolTipPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@
using Winterdom.Viasfora.Design;

namespace Winterdom.Viasfora.Rainbow {
// Commenting this out, as I am not sure it's really needed anymore,
// and I can't find a way to convert the IQuickInfoSession usage
// to IAsyncQuickInfoSession since there's functionality missing there
/*
[Export(typeof(IIntellisensePresenterProvider))]
[Name("viasfora.rainbow.tooltip.presenter")]
[Order(Before="Default Quick Info Presenter")]
[ContentType(ContentTypes.Text)]
*/
public class RainbowToolTipPresenterProvider : IIntellisensePresenterProvider {
[Import]
public ITextEditorFactoryService EditorFactory { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions src/Viasfora.Rainbow/Viasfora.Rainbow.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json">
<Version>13.0.1</Version>
<Version>13.0.3</Version>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Sdk">
<Version>17.1.32210.191</Version>
<Version>17.6.36389</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Viasfora.Settings/Viasfora.Settings.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json">
<Version>13.0.1</Version>
<Version>13.0.3</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Viasfora.Xml/Viasfora.Xml.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Sdk">
<Version>17.1.32210.191</Version>
<Version>17.6.36389</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
Expand Down
5 changes: 5 additions & 0 deletions src/Viasfora.Xml/XmlConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ public static class XmlConstants {
public const String XML_PREFIX = "viasfora.xml.prefix";
public const String XML_CLOSING_PREFIX = "viasfora.xml.closing.prefix";
public const String RAZOR_CLOSING = "viasfora.razor.closing.element";

// VS2022 Editors
public const String CT_WEBFORMS = "WebForms";
public const String CT_RAZOR = "Razor";

// I'd prefer "XML Delimiter" here, but no way to
// use it effectively.
public const String DELIMITER = PredefinedClassificationTypeNames.Operator;
Expand Down
6 changes: 4 additions & 2 deletions src/Viasfora.Xml/XmlQuickInfoController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
Expand All @@ -8,7 +9,6 @@ namespace Winterdom.Viasfora.Xml {
internal class XmlQuickInfoController : IIntellisenseController {
private ITextView textView;
private IList<ITextBuffer> textBuffers;
private IQuickInfoSession session;
private XmlQuickInfoControllerProvider provider;

internal XmlQuickInfoController(
Expand Down Expand Up @@ -44,9 +44,11 @@ void OnTextViewMouseHover(object sender, MouseHoverEventArgs e) {
ITrackingPoint triggerPoint = point.Value.Snapshot.CreateTrackingPoint(
point.Value.Position, PointTrackingMode.Positive);
if ( this.provider.QuickInfoBroker.IsQuickInfoActive(this.textView) ) {
this.session = this.provider.QuickInfoBroker.TriggerQuickInfo(this.textView, triggerPoint, true);
Task task = this.provider.QuickInfoBroker.TriggerQuickInfoAsync(this.textView, triggerPoint);
// Can't wait until it's done. Just let it happen Async
}
}
}
}

}
2 changes: 1 addition & 1 deletion src/Viasfora.Xml/XmlQuickInfoControllerProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Winterdom.Viasfora.Xml {
[ContentType(XmlConstants.CT_XAML)]
internal class XmlQuickInfoControllerProvider : IIntellisenseControllerProvider {
[Import]
internal IQuickInfoBroker QuickInfoBroker { get; set; }
internal IAsyncQuickInfoBroker QuickInfoBroker { get; set; }

public IIntellisenseController TryCreateIntellisenseController(
ITextView textView, IList<ITextBuffer> subjectBuffers) {
Expand Down
4 changes: 3 additions & 1 deletion src/Viasfora.Xml/XmlTagger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public IEnumerable<ITagSpan<ClassificationTag>> GetTags(NormalizedSnapshotSpanCo
this.language = this.language ?? new XamlMarkup();
return DoXAMLorHTML(spans);
} else if ( fileType.IsOfType(XmlConstants.CT_HTML)
|| fileType.IsOfType(XmlConstants.CT_HTMLX) ) {
|| fileType.IsOfType(XmlConstants.CT_HTMLX)
|| fileType.IsOfType(XmlConstants.CT_RAZOR)
|| fileType.IsOfType(XmlConstants.CT_WEBFORMS) ) {
this.language = this.language ?? new HtmlMarkup();
return DoXAMLorHTML(spans);
}
Expand Down
2 changes: 2 additions & 0 deletions src/Viasfora.Xml/XmlTaggerProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace Winterdom.Viasfora.Xml {
[ContentType(XmlConstants.CT_XAML)]
[ContentType(XmlConstants.CT_HTML)]
[ContentType(XmlConstants.CT_HTMLX)]
[ContentType(XmlConstants.CT_WEBFORMS)]
[ContentType(XmlConstants.CT_RAZOR)]
[TagType(typeof(ClassificationTag))]
public class XmlTaggerProvider : IViewTaggerProvider {
[Import]
Expand Down
6 changes: 3 additions & 3 deletions src/Viasfora/Viasfora.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,13 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json">
<Version>13.0.1</Version>
<Version>13.0.3</Version>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Sdk">
<Version>17.1.32210.191</Version>
<Version>17.6.36389</Version>
</PackageReference>
<PackageReference Include="Microsoft.VSSDK.BuildTools">
<Version>17.0.5232</Version>
<Version>17.3.2094</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
2 changes: 1 addition & 1 deletion src/Viasfora/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="Winterdom.Viasfora.f7a33795-2b40-4125-856c-89b0bd8cd5ab"
Version="4.4"
Version="4.5"
Language="en-US"
Publisher="Tomas Restrepo" />
<DisplayName>Viasfora</DisplayName>
Expand Down
14 changes: 14 additions & 0 deletions tests/Viasfora.Tests/BraceScanners/CBraceScannerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ public void CanExtractBracesFollowingCpp14QuoteInHexLiteral() {
var chars = Extract(extractor, input.Trim(), 0, 0);
Assert.Equal(4, chars.Count);
}
[Fact]
public void CanExtractBracesFollowingUtf8LiteralChar() {
String input = @"x = (u8' ')";
var extractor = new CBraceScanner();
var chars = Extract(extractor, input.Trim(), 0, 0);
Assert.Equal(2, chars.Count);
}
[Fact]
public void CanExtractBracesFollowingUtf8LiteralString() {
String input = "x = (u8\" \")";
var extractor = new CBraceScanner();
var chars = Extract(extractor, input.Trim(), 0, 0);
Assert.Equal(2, chars.Count);
}
[Fact]
public void CanExtractBracesFollowingCpp14QuoteInIntLiteralHex() {
String input = @"if ( x == 0x80'00 ) { }";
Expand Down
Loading

0 comments on commit b200a75

Please sign in to comment.