Skip to content

Commit f51e835

Browse files
committed
Updating for v4.2 release
2 parents 92714de + 2ffa27f commit f51e835

File tree

13 files changed

+389
-312
lines changed

13 files changed

+389
-312
lines changed

src/Viasfora.Core/Text/KeywordTagger.cs

Lines changed: 200 additions & 192 deletions
Large diffs are not rendered by default.

src/Viasfora.Core/Text/KeywordTaggerProvider.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
using Microsoft.VisualStudio.Utilities;
99
using Winterdom.Viasfora.Tags;
1010
using Winterdom.Viasfora.Languages;
11-
11+
using System.Threading.Tasks;
12+
1213
namespace Winterdom.Viasfora.Text {
1314

1415
[Export(typeof(IViewTaggerProvider))]
@@ -97,14 +98,24 @@ private void FixItalics() {
9798
}
9899
} finally {
99100
this.formatMap.EndBatchUpdate();
100-
this.working = false;
101+
// If we change the formats, the corresponding
102+
// format map update event could fire just after we leave
103+
// this block, causing cascading calls.
104+
// To avoid this, delay resetting the working flag
105+
// until after some small time has passed.
106+
Task.Delay(500).ContinueWith(
107+
(parentTask) => this.working = false
108+
);
101109
}
102110
}
111+
103112
private void SetItalics(IClassificationType classifierType, bool enable) {
104113
var tp = this.formatMap.GetTextProperties(classifierType);
105114

106-
tp = tp.SetItalic(enable);
107-
this.formatMap.SetTextProperties(classifierType, tp);
115+
if ( !tp.Italic ) {
116+
tp = tp.SetItalic(enable);
117+
this.formatMap.SetTextProperties(classifierType, tp);
118+
}
108119
}
109120
}
110121
}

src/Viasfora.Core/Viasfora.Core.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '15.0' ">
3131
<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
3232
</PropertyGroup>
33+
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '16.0' ">
34+
<MinimumVisualStudioVersion>16.0</MinimumVisualStudioVersion>
35+
</PropertyGroup>
3336
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
3437
<Prefer32Bit>false</Prefer32Bit>
3538
</PropertyGroup>

src/Viasfora.Languages/BraceScanners/CSharpBraceScanner.cs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class CSharpBraceScanner : IBraceScanner, IResumeControl {
1313

1414
private int status = stText;
1515
private int nestingLevel = 0;
16+
private int istringNestLevel = 0;
1617
private bool parsingExpression = false;
1718
private bool multiLine = false;
1819

@@ -26,6 +27,7 @@ public void Reset(int state) {
2627
this.parsingExpression = (state & 0x08000000) != 0;
2728
this.nestingLevel = (state & 0xFF0000) >> 24;
2829
this.multiLine = (state & 0x04000000) != 0;
30+
this.istringNestLevel = (state & 0xFF00) >> 16;
2931
}
3032

3133
public bool CanResume(CharPos brace) {
@@ -168,7 +170,23 @@ private bool ParseInterpolatedString(ITextChars tc, ref CharPos pos) {
168170
//
169171
// we're inside an interpolated section
170172
//
171-
if ( tc.Char() == '"' ) {
173+
if ( tc.Char() == '$' && tc.NChar() == '"' ) {
174+
// opening nested interpolated string
175+
tc.Skip(2);
176+
this.parsingExpression = false;
177+
this.istringNestLevel++;
178+
this.nestingLevel = 0;
179+
if ( this.ParseInterpolatedString(tc, ref pos) )
180+
return true;
181+
this.istringNestLevel--;
182+
this.parsingExpression = true;
183+
this.status = stIString;
184+
} else if ( tc.Char() == '@' && tc.NChar() == '"' ) {
185+
// opening nested verbatim string
186+
tc.Skip(2);
187+
this.ParseMultiLineString(tc);
188+
this.status = stIString;
189+
} else if ( tc.Char() == '"' ) {
172190
// opening string
173191
tc.Next();
174192
this.ParseString(tc);
@@ -216,8 +234,15 @@ private bool ParseInterpolatedString(ITextChars tc, ref CharPos pos) {
216234
tc.Skip(2);
217235
} else if ( tc.Char() == '"' ) {
218236
// done parsing the interpolated string
219-
this.status = stText;
220237
this.multiLine = false;
238+
this.istringNestLevel--;
239+
if (this.istringNestLevel <= 0) {
240+
this.istringNestLevel = 0;
241+
this.status = stText;
242+
} else {
243+
this.status = stIString;
244+
this.parsingExpression = true;
245+
}
221246
tc.Next();
222247
break;
223248
} else {
@@ -235,6 +260,7 @@ private int EncodedState() {
235260
if ( this.multiLine )
236261
encoded |= 0x04000000;
237262
encoded |= (this.nestingLevel & 0xFF) << 24;
263+
encoded |= (this.istringNestLevel & 0xFF) << 16;
238264
return encoded;
239265
}
240266
}

src/Viasfora.Languages/Cpp.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Winterdom.Viasfora.Languages {
88
[Export(typeof(ILanguage))]
99
class Cpp : CBasedLanguage, ILanguage {
1010
private readonly static String[] knownTypes =
11-
new String[] { "C/C++", "HLSL" };
11+
new String[] { "C/C++", "HLSL", "C/C++ (VisualGDB)" };
1212

1313
protected override String[] SupportedContentTypes
1414
=> knownTypes;

src/Viasfora.Languages/Viasfora.Languages.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@
2727
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '14.0' ">
2828
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
2929
</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>
35+
</PropertyGroup>
3036
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
3137
<Prefer32Bit>false</Prefer32Bit>
3238
</PropertyGroup>

src/Viasfora.Rainbow/RainbowLines.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,17 @@ private double CalculateLeftOfFirstChar(SnapshotPoint open, IFormattedLineSource
298298
var line = open.GetContainingLine();
299299
var x = 0d;
300300
var start = line.Start;
301+
int spacesSinceLastTab = 0;
301302
while ( Char.IsWhiteSpace(start.GetChar()) ) {
302-
x += start.GetChar() == '\t' ? fls.TabSize * fls.ColumnWidth : fls.ColumnWidth;
303+
char ch = start.GetChar();
304+
if ( ch == ' ' ) {
305+
spacesSinceLastTab = ++spacesSinceLastTab % fls.TabSize;
306+
x += fls.ColumnWidth;
307+
} else if ( ch == '\t' ) {
308+
x += ((fls.TabSize - spacesSinceLastTab) * fls.ColumnWidth);
309+
spacesSinceLastTab = 0;
310+
}
311+
//x += start.GetChar() == '\t' ? fls.TabSize * fls.ColumnWidth : fls.ColumnWidth;
303312
start = start + 1;
304313
}
305314
return x;

src/Viasfora.Rainbow/Viasfora.Rainbow.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '15.0' ">
3030
<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
3131
</PropertyGroup>
32+
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '16.0' ">
33+
<MinimumVisualStudioVersion>16.0</MinimumVisualStudioVersion>
34+
</PropertyGroup>
3235
<ItemGroup>
3336
<Reference Include="envdte, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
3437
<EmbedInteropTypes>False</EmbedInteropTypes>

src/Viasfora.Xml/Viasfora.Xml.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '15.0' ">
3131
<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
3232
</PropertyGroup>
33+
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '16.0' ">
34+
<MinimumVisualStudioVersion>16.0</MinimumVisualStudioVersion>
35+
</PropertyGroup>
3336
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
3437
<Prefer32Bit>false</Prefer32Bit>
3538
</PropertyGroup>

src/Viasfora/Telemetry.cs

Lines changed: 103 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,106 @@
1-
using Microsoft.ApplicationInsights;
2-
using Microsoft.ApplicationInsights.DataContracts;
3-
using Microsoft.ApplicationInsights.Extensibility;
4-
using System;
5-
using System.Diagnostics;
6-
using System.IO;
7-
using System.Linq;
8-
using System.Reflection;
9-
using System.Security.Cryptography;
10-
using System.Text;
11-
12-
namespace Winterdom.Viasfora {
13-
public class Telemetry {
14-
private TelemetryClient client;
15-
public bool Enabled { get; private set; }
16-
17-
public Telemetry(bool enabled, EnvDTE80.DTE2 dte = null) {
18-
TelemetryConfiguration config = TelemetryConfiguration.CreateDefault();
19-
20-
this.client = new TelemetryClient(config);
21-
this.client.InstrumentationKey = "b59d19eb-668d-4ae3-b4c8-71536ebabbdc";
22-
23-
this.client.Context.User.Id = GetUserId();
24-
this.client.Context.Session.Id = Guid.NewGuid().ToString();
25-
this.client.Context.Properties.Add("Host", dte.Application.Edition);
26-
this.client.Context.Properties.Add("HostVersion", dte.Version);
27-
this.client.Context.Properties.Add("HostFullVersion", GetFullHostVersion());
28-
this.client.Context.Component.Version = GetViasforaVersion();
29-
this.client.Context.Properties.Add("AppVersion", GetFullHostVersion());
30-
this.client.Context.Device.OperatingSystem = Environment.OSVersion.ToString();
31-
1+
using Microsoft.ApplicationInsights;
2+
using Microsoft.ApplicationInsights.DataContracts;
3+
using Microsoft.ApplicationInsights.Extensibility;
4+
using System;
5+
using System.Diagnostics;
6+
using System.IO;
7+
using System.Linq;
8+
using System.Reflection;
9+
using System.Security.Cryptography;
10+
using System.Text;
11+
12+
namespace Winterdom.Viasfora {
13+
public class Telemetry {
14+
private TelemetryClient client;
15+
public bool Enabled { get; private set; }
16+
17+
public Telemetry(bool enabled, EnvDTE80.DTE2 dte = null) {
18+
TelemetryConfiguration config = TelemetryConfiguration.CreateDefault();
19+
20+
this.client = new TelemetryClient(config);
21+
this.client.InstrumentationKey = "b59d19eb-668d-4ae3-b4c8-71536ebabbdc";
22+
23+
this.client.Context.User.Id = GetUserId();
24+
this.client.Context.Session.Id = Guid.NewGuid().ToString();
25+
this.client.Context.Properties.Add("Host", "VS");
26+
this.client.Context.Properties.Add("HostVersion", dte.Version);
27+
this.client.Context.Properties.Add("HostFullVersion", GetFullHostVersion());
28+
this.client.Context.Component.Version = GetViasforaVersion();
29+
3230
if (enabled && dte != null) {
3331
dte.Events.DTEEvents.OnBeginShutdown += OnBeginShutdown;
3432
}
35-
36-
Enabled = enabled;
37-
38-
WriteEvent("Viasfora Started");
39-
}
40-
41-
public void WriteEvent(String eventName) {
42-
#if !DEBUG
43-
if ( this.client != null && Enabled ) {
44-
this.client.TrackEvent(new EventTelemetry(eventName));
45-
}
46-
#endif
47-
}
48-
49-
public void WriteEvent(EventTelemetry evt) {
50-
#if !DEBUG
51-
if ( this.client != null && Enabled ) {
52-
this.client.TrackEvent(evt);
53-
}
54-
#endif
55-
}
56-
57-
public void WriteException(String msg, Exception ex) {
58-
#if !DEBUG
59-
if ( this.client != null && Enabled ) {
60-
ExceptionTelemetry telemetry = new ExceptionTelemetry(ex);
61-
telemetry.Properties.Add("Message", msg);
62-
this.client.TrackException(telemetry);
63-
}
64-
#endif
65-
}
66-
67-
public void WriteTrace(String message) {
68-
#if !DEBUG
69-
if ( this.client != null && Enabled ) {
70-
this.client.TrackTrace(message);
71-
}
72-
#endif
73-
}
74-
75-
private void OnBeginShutdown() {
76-
this.client.Flush();
77-
}
78-
79-
private static String GetFullHostVersion() {
80-
try {
81-
String baseDir = AppDomain.CurrentDomain.BaseDirectory;
82-
String devenv = Path.Combine(baseDir, "msenv.dll");
83-
var version = FileVersionInfo.GetVersionInfo(devenv);
84-
return version.ProductVersion;
85-
} catch {
86-
// Ignore if we cannot get
87-
}
88-
return "";
89-
}
90-
91-
private static String GetViasforaVersion() {
92-
var assembly = typeof(Telemetry).Assembly;
93-
var fileVersion = assembly
94-
.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false)
95-
.Cast<AssemblyFileVersionAttribute>()
96-
.First().Version;
97-
return fileVersion;
98-
}
99-
100-
private static String GetUserId() {
101-
var user = Environment.MachineName + "\\" + Environment.UserName;
102-
var bytes = Encoding.UTF8.GetBytes(user);
103-
using ( var sha = SHA256.Create() ) {
104-
return Convert.ToBase64String(sha.ComputeHash(bytes));
105-
}
106-
}
107-
}
108-
}
33+
34+
Enabled = enabled;
35+
36+
WriteEvent("Viasfora Started");
37+
}
38+
39+
public void WriteEvent(String eventName) {
40+
#if !DEBUG
41+
if ( this.client != null && Enabled ) {
42+
this.client.TrackEvent(new EventTelemetry(eventName));
43+
}
44+
#endif
45+
}
46+
47+
public void WriteEvent(EventTelemetry evt) {
48+
#if !DEBUG
49+
if ( this.client != null && Enabled ) {
50+
this.client.TrackEvent(evt);
51+
}
52+
#endif
53+
}
54+
55+
public void WriteException(String msg, Exception ex) {
56+
#if !DEBUG
57+
if ( this.client != null && Enabled ) {
58+
ExceptionTelemetry telemetry = new ExceptionTelemetry(ex);
59+
telemetry.Properties.Add("Message", msg);
60+
this.client.TrackException(telemetry);
61+
}
62+
#endif
63+
}
64+
65+
public void WriteTrace(String message) {
66+
#if !DEBUG
67+
if ( this.client != null && Enabled ) {
68+
this.client.TrackTrace(message);
69+
}
70+
#endif
71+
}
72+
73+
private void OnBeginShutdown() {
74+
this.client.Flush();
75+
}
76+
77+
private static String GetFullHostVersion() {
78+
try {
79+
String baseDir = AppDomain.CurrentDomain.BaseDirectory;
80+
String devenv = Path.Combine(baseDir, "msenv.dll");
81+
var version = FileVersionInfo.GetVersionInfo(devenv);
82+
return version.ProductVersion;
83+
} catch {
84+
// Ignore if we cannot get
85+
}
86+
return "";
87+
}
88+
89+
private static String GetViasforaVersion() {
90+
var assembly = typeof(Telemetry).Assembly;
91+
var fileVersion = assembly
92+
.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false)
93+
.Cast<AssemblyFileVersionAttribute>()
94+
.First().Version;
95+
return fileVersion;
96+
}
97+
98+
private static String GetUserId() {
99+
var user = Environment.MachineName + "\\" + Environment.UserName;
100+
var bytes = Encoding.UTF8.GetBytes(user);
101+
using ( var sha = SHA256.Create() ) {
102+
return Convert.ToBase64String(sha.ComputeHash(bytes));
103+
}
104+
}
105+
}
106+
}

src/Viasfora/Viasfora.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@
6666
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '15.0' ">
6767
<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
6868
</PropertyGroup>
69+
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '16.0' ">
70+
<MinimumVisualStudioVersion>16.0</MinimumVisualStudioVersion>
71+
</PropertyGroup>
6972
<PropertyGroup>
7073
<SignAssembly>false</SignAssembly>
7174
</PropertyGroup>

0 commit comments

Comments
 (0)