Skip to content

Commit

Permalink
v2.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
NotroDev committed Jan 21, 2024
1 parent faab0af commit 6da2221
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Installer/Package.wxs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">
<Package Name="SkEditor" Manufacturer="Notro" Version="2.1.1" UpgradeCode="14564974-da58-4917-8a0d-590043f589c2">
<Package Name="SkEditor" Manufacturer="Notro" Version="2.1.2" UpgradeCode="14564974-da58-4917-8a0d-590043f589c2">
<MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" />
<MediaTemplate EmbedCab="yes" />

Expand Down
5 changes: 4 additions & 1 deletion SkEditor/API/AddonLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace SkEditor.API;
public class AddonLoader
{
public static List<IAddon> Addons { get; } = [];
public static HashSet<string> DllNames { get; } = [];

public static void Load()
{
Expand Down Expand Up @@ -55,8 +56,9 @@ private static void UpdateAddons(string addonFolder)
{
string nameWithoutPrefix = Path.GetFileName(updatedAddon)["updated-".Length..];
string folderWithoutPrefixPath = Path.Combine(addonFolder, Path.GetFileNameWithoutExtension(nameWithoutPrefix));
if (Directory.Exists(folderWithoutPrefixPath))
if (!Directory.Exists(folderWithoutPrefixPath))
{
Log.Warning($"Found \"{updatedAddon}\" in addons folder, but its folder \"{folderWithoutPrefixPath}\" doesn't exist. Deleting it.");
File.Delete(updatedAddon);
continue;
}
Expand Down Expand Up @@ -121,6 +123,7 @@ public static List<Assembly> LoadAddonsFromFolder(string folder)
if (AppDomain.CurrentDomain.GetAssemblies().Any(a => a.GetName().Name == Path.GetFileNameWithoutExtension(dllFile))) continue;

assemblies.Add(Assembly.LoadFrom(dllFile));
DllNames.Add(fileName);
}

return assemblies;
Expand Down
9 changes: 8 additions & 1 deletion SkEditor/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using SkEditor.API;
using System;
using System.Diagnostics;
using System.Linq;

namespace SkEditor.Desktop;

Expand All @@ -21,7 +22,13 @@ public static void Main(string[] args)
}
catch (Exception e)
{
Log.Fatal(e, "Application crashed!");
string message = "Application crashed!";
string? source = e.Source;
if (AddonLoader.DllNames.Contains(source + ".dll"))
{
message += $" It's fault of {source} addon.";
}
Log.Fatal(e, message);

ApiVault.Get().SaveData();

Expand Down
6 changes: 3 additions & 3 deletions SkEditor/SkEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationIcon>SkEditor.ico</ApplicationIcon>
<PublishSingleFile>true</PublishSingleFile>
<AssemblyVersion>2.1.1</AssemblyVersion>
<FileVersion>2.1.1</FileVersion>
<Version>2.1.1</Version>
<AssemblyVersion>2.1.2</AssemblyVersion>
<FileVersion>2.1.2</FileVersion>
<Version>2.1.2</Version>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>CS8600;CS8604;CS8622;CS8603;CS8602;CA2211;CS8619;CS8629;CS8601;CS8618;CS8620</NoWarn>
Expand Down
13 changes: 9 additions & 4 deletions SkEditor/Utilities/Editor/TextEditorEventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public partial class TextEditorEventHandler
};

private const string commentPattern = @"#(?!#(?:\s*#[^#]*)?)\s*[^#]*$";
private static Regex _commentRegex = new(commentPattern, RegexOptions.Compiled);
private static Regex _commentRegex = CommentRegex();

public static Dictionary<TextEditor, ScrollViewer> ScrollViewers { get; } = [];

Expand Down Expand Up @@ -135,9 +135,12 @@ public static void DoAutoPairing(object? sender, TextInputEventArgs e)
if (nextChar.Equals(value)) return;
}

string textBefore = textEditor.Document.GetText(0, textEditor.CaretOffset);
int count = textBefore.Count(c => c == symbol);
if (count % 2 == 0) return;
int lineOffset = textEditor.Document.GetLineByOffset(textEditor.CaretOffset).Offset;
string textBefore = textEditor.Document.GetText(lineOffset, textEditor.CaretOffset - lineOffset - 1);
int count1 = textBefore.Count(c => c == symbol);
int count2 = textBefore.Count(c => c == value);
if (symbol == value && count1 % 2 == 1) return;
if (count1 > count2) return;

textEditor.Document.Insert(textEditor.CaretOffset, value.ToString());
textEditor.CaretOffset--;
Expand Down Expand Up @@ -232,4 +235,6 @@ public static void OnTextPasting(object? sender, TextEventArgs e)
private static partial Regex HexRegex();
[GeneratedRegex("")]
private static partial Regex EmptyRegex();
[GeneratedRegex(commentPattern, RegexOptions.Compiled)]
private static partial Regex CommentRegex();
}
25 changes: 13 additions & 12 deletions SkEditor/Utilities/Projects/ProjectOpener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,23 @@ public async static void AddChildren(TreeViewItem viewItem, IStorageFolder folde
viewItem.Items.Add(folderItem);

AddChildren(folderItem, storageFolder);
return;
}

TreeViewItem item = new()
else
{
Header = Path.GetFileName(path),
Tag = path,
FontWeight = FontWeight.Normal
};
TreeViewItem item = new()
{
Header = Path.GetFileName(path),
Tag = path,
FontWeight = FontWeight.Normal
};

item.DoubleTapped += (sender, e) =>
{
FileHandler.OpenFile(path);
};
item.DoubleTapped += (sender, e) =>
{
FileHandler.OpenFile(path);
};

viewItem.Items.Add(item);
viewItem.Items.Add(item);
}
}
}
}
3 changes: 2 additions & 1 deletion SkEditor/Utilities/Syntax/SyntaxLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ public static async Task RefreshSyntaxAsync(string? extension = null)

if (extension == null)
{
extension = Path.GetExtension((ApiVault.Get().GetTabView().SelectedItem as TabViewItem).Tag.ToString());

extension = Path.GetExtension((ApiVault.Get().GetTabView().SelectedItem as TabViewItem).Tag?.ToString());
if (string.IsNullOrWhiteSpace(extension) || !SortedFileSyntaxes.ContainsKey(extension))
{
editor.SyntaxHighlighting = defaultSyntax.Highlighting;
Expand Down

0 comments on commit 6da2221

Please sign in to comment.