diff --git a/src/HexManiac.Core/ViewModels/Tools/TableTool.cs b/src/HexManiac.Core/ViewModels/Tools/TableTool.cs index 39c0249a..fa6d1dfb 100644 --- a/src/HexManiac.Core/ViewModels/Tools/TableTool.cs +++ b/src/HexManiac.Core/ViewModels/Tools/TableTool.cs @@ -203,8 +203,13 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Tools { var (start, end) = (selection.Scroll.ViewPointToDataIndex(selection.SelectionStart), selection.Scroll.ViewPointToDataIndex(selection.SelectionEnd)); var array = (ITableRun)model.GetNextRun(address); - start -= array.ElementLength; - end -= array.ElementLength; + if (array.Start <= start && start < array.Start + array.Length && array.Start <= end && end < array.Start + array.Length) { + start -= array.ElementLength; + end -= array.ElementLength; + } else { + start = address - array.ElementLength; + end = address - 1; + } selection.SelectionStart = selection.Scroll.DataIndexToViewPoint(start); selection.SelectionEnd = selection.Scroll.DataIndexToViewPoint(end); } @@ -222,8 +227,13 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Tools { var (start, end) = (selection.Scroll.ViewPointToDataIndex(selection.SelectionStart), selection.Scroll.ViewPointToDataIndex(selection.SelectionEnd)); var array = (ITableRun)model.GetNextRun(address); - start += array.ElementLength; - end += array.ElementLength; + if (array.Start <= start && start < array.Start + array.Length && array.Start <= end && end < array.Start + array.Length) { + start += array.ElementLength; + end += array.ElementLength; + } else { + start = address + array.ElementLength; + end = address + array.ElementLength * 2 - 1; + } selection.SelectionStart = selection.Scroll.DataIndexToViewPoint(start); selection.SelectionEnd = selection.Scroll.DataIndexToViewPoint(end); } diff --git a/src/HexManiac.Integration/DataTests.cs b/src/HexManiac.Integration/DataTests.cs index 39ece0d6..a16a9c72 100644 --- a/src/HexManiac.Integration/DataTests.cs +++ b/src/HexManiac.Integration/DataTests.cs @@ -30,7 +30,7 @@ namespace HavenSoft.HexManiac.Integration { } [SkippableFact] - public void BrockScript_ExpandSelection_EntireScriptSelected() { + public void BrockScript_ExpandSelection_MultipleSectionsSelected() { var firered = LoadReadOnlyFireRed(); firered.Goto.Execute("data.maps.banks/6/maps/2/map/0/events/0/objects/0/script/"); @@ -39,7 +39,7 @@ namespace HavenSoft.HexManiac.Integration { var firstAddress = firered.ConvertViewPointToAddress(firered.SelectionStart); var lastAddress = firered.ConvertViewPointToAddress(firered.SelectionEnd); var length = lastAddress - firstAddress + 1; - Assert.Equal(171, length); + Assert.Equal(95, length); } [SkippableFact] diff --git a/src/HexManiac.Integration/HexManiac.Integration.csproj b/src/HexManiac.Integration/HexManiac.Integration.csproj index 58f459eb..773d41eb 100644 --- a/src/HexManiac.Integration/HexManiac.Integration.csproj +++ b/src/HexManiac.Integration/HexManiac.Integration.csproj @@ -45,6 +45,8 @@ del "$(TargetDir)Models\Code\*.toml" copy "$(TargetDir)Models\Code\*.hma" "$(TargetDir)resources" del "$(TargetDir)Models\Code\*.hma" + copy "$(TargetDir)Models\Code\*.py" "$(TargetDir)resources" + del "$(TargetDir)Models\Code\*.py" copy "$(SolutionDir)src\HexManiac.WPF\Scripts\*.hma" "$(TargetDir)resources\Scripts" diff --git a/src/HexManiac.Tests/HexManiac.Tests.csproj b/src/HexManiac.Tests/HexManiac.Tests.csproj index f33a0eee..fa8917a7 100644 --- a/src/HexManiac.Tests/HexManiac.Tests.csproj +++ b/src/HexManiac.Tests/HexManiac.Tests.csproj @@ -61,6 +61,8 @@ del "$(TargetDir)Models\Code\*.toml" copy "$(TargetDir)Models\Code\*.hma" "$(TargetDir)resources" del "$(TargetDir)Models\Code\*.hma" + copy "$(TargetDir)Models\Code\*.py" "$(TargetDir)resources" + del "$(TargetDir)Models\Code\*.py" copy "$(SolutionDir)src\HexManiac.WPF\Scripts\*.hma" "$(TargetDir)resources\Scripts"