mirror of
https://github.com/haven1433/HexManiacAdvance.git
synced 2026-06-01 13:03:39 -05:00
don't allow writing nameless anchors with nothing pointing to them
This commit is contained in:
parent
762e719984
commit
e26cf56a2b
|
|
@ -762,7 +762,18 @@ namespace HavenSoft.HexManiac.Core.ViewModels {
|
|||
}
|
||||
if (run.Start <= index) {
|
||||
var token = new NoDataChangeDeltaModel();
|
||||
var errorInfo = PokemonModel.ApplyAnchor(Model, token, run.Start, AnchorText);
|
||||
|
||||
// During edits, typing `^` is allowed, and is used as a way to remove an anchor.
|
||||
// When doing AnchorText edits, clearing the name/format when there are no pointers is an error.
|
||||
ErrorInfo errorInfo = ErrorInfo.NoError;
|
||||
if (AnchorText == AnchorStart.ToString() && run.PointerSources.Count == 0) {
|
||||
errorInfo = new ErrorInfo("An anchor with nothing pointing to it must have a name.");
|
||||
}
|
||||
|
||||
if (errorInfo == ErrorInfo.NoError) {
|
||||
errorInfo = PokemonModel.ApplyAnchor(Model, token, run.Start, AnchorText);
|
||||
}
|
||||
|
||||
if (errorInfo == ErrorInfo.NoError) {
|
||||
OnError?.Invoke(this, string.Empty);
|
||||
var newRun = Model.GetNextRun(index);
|
||||
|
|
|
|||
|
|
@ -658,6 +658,16 @@ namespace HavenSoft.HexManiac.Tests {
|
|||
Assert.True(ViewPort.ChangeHistory.IsSaved);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TextAnchor_ChangeToNoInfoAnchor_NoNameIsError() {
|
||||
SetFullModel(0xFF);
|
||||
ViewPort.Edit("^text\"\" ");
|
||||
|
||||
ViewPort.AnchorText = "^";
|
||||
|
||||
Assert.NotEmpty(Errors);
|
||||
}
|
||||
|
||||
private void Write(IDataModel model, ref int i, string characters) {
|
||||
foreach (var c in characters.ToCharArray())
|
||||
model[i++] = (byte)PCSString.PCS.IndexOf(c.ToString());
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user