mirror of
https://github.com/haven1433/HexManiacAdvance.git
synced 2026-05-31 20:42:43 -05:00
Fix table tool: streams should not have leading '+' on each line
This commit is contained in:
parent
90dc561e2e
commit
c87c6afca2
|
|
@ -94,7 +94,15 @@ namespace HavenSoft.HexManiac.Core.Models.Runs {
|
|||
public string SerializeRun() {
|
||||
var builder = new StringBuilder();
|
||||
AppendTo(model, builder, Start, ElementLength * ElementCount);
|
||||
return builder.ToString();
|
||||
var lines = builder.ToString().Split(Environment.NewLine);
|
||||
|
||||
// AppendTo is used in copy/paste scenarios, and includes the required '+' to work in that case.
|
||||
// strip the '+', as it's not needed for stream serialization, which uses newlines instead.
|
||||
return string.Join(Environment.NewLine, lines.Select(line => {
|
||||
if (line.Length == 0) return line;
|
||||
if (line[0] != ArrayRun.ExtendArray) return line;
|
||||
return line.Substring(1);
|
||||
}).ToArray());
|
||||
}
|
||||
|
||||
public IStreamRun DeserializeRun(string content, ModelDelta token) {
|
||||
|
|
|
|||
|
|
@ -66,9 +66,9 @@ namespace HavenSoft.HexManiac.Tests {
|
|||
ViewPort.Edit("00 01 02 03 FF ^bob CC @00 ^table[value.]!FF ");
|
||||
ViewPort.Tools.SelectedIndex = ViewPort.Tools.IndexOf(ViewPort.Tools.StringTool);
|
||||
Assert.Equal(@"0
|
||||
+1
|
||||
+2
|
||||
+3", ViewPort.Tools.StringTool.Content);
|
||||
1
|
||||
2
|
||||
3", ViewPort.Tools.StringTool.Content);
|
||||
|
||||
ViewPort.Tools.StringTool.Content = @"0
|
||||
1
|
||||
|
|
|
|||
|
|
@ -257,10 +257,10 @@ namespace HavenSoft.HexManiac.Tests {
|
|||
|
||||
// precondition: the format is as expected
|
||||
Assert.Equal(@"255
|
||||
+255
|
||||
+255
|
||||
+255
|
||||
+255", segment.Content);
|
||||
255
|
||||
255
|
||||
255
|
||||
255", segment.Content);
|
||||
|
||||
// Act: change the content in a way that would change the length of a more dynamic stream.
|
||||
segment.Content = "12";
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user