mirror of
https://github.com/haven1433/HexManiacAdvance.git
synced 2026-10-01 20:56:36 -05:00
fix script selection bug
if the script start changes and the script end doesn't change, we still need to update the script shown in the code tool.
This commit is contained in:
@@ -110,7 +110,9 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Tools {
|
||||
this.history = history;
|
||||
this.messageTab = messageTab;
|
||||
selection.PropertyChanged += (sender, e) => {
|
||||
if (e.PropertyName == nameof(selection.SelectionEnd)) {
|
||||
if (e.PropertyName == nameof(selection.SelectionStart)) {
|
||||
if (selection.SelectionStart == selection.SelectionEnd) UpdateContent();
|
||||
} else if (e.PropertyName == nameof(selection.SelectionEnd)) {
|
||||
UpdateContent();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace HavenSoft.HexManiac.Tests {
|
||||
public class CodeToolTests : BaseViewModelTestClass {
|
||||
private CodeTool Tool => ViewPort.Tools.CodeTool;
|
||||
private string EventScript {
|
||||
get => ";".Join(Tool.Contents[0].Content.SplitLines().Select(line => line.Trim()));
|
||||
get => ";".Join(Tool.Contents[0].Content.SplitLines().Where(line => !string.IsNullOrWhiteSpace(line)).Select(line => line.Trim()));
|
||||
set {
|
||||
Tool.Mode = CodeMode.Script;
|
||||
Tool.Contents[0].Content = value.Replace(";", Environment.NewLine);
|
||||
@@ -891,5 +891,16 @@ label2:;goto <000050>;end";
|
||||
var expected = "21 00 40 07 00 06 01 10 00 72 08 02".ToByteArray();
|
||||
Assert.All(expected.Length.Range(), i => Assert.Equal(expected[i], Model[i]));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EntireScriptSelected_SelectLastByte_ShownScriptUpdated() {
|
||||
EventScript = "nop;end";
|
||||
ViewPort.SelectionStart = new(0, 0);
|
||||
ViewPort.SelectionEnd = new(1, 0);
|
||||
|
||||
ViewPort.SelectionStart = new(1, 0);
|
||||
|
||||
Assert.Equal("end", EventScript);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user