What is the current behavior?
Node titles with trailing spaces include the space in the parsed node title. This contrasts with TryGetNodeTitle that trims the trailing space.
Please provide the steps to reproduce, and if possible a minimal demo of the problem:
define a node with a trailing space after the title:
Query for its existence:
public void TestLoadingNodes()
{
var path = Path.Combine(TestDataPath, "Projects", "Basic", "Test.yarn");
var result = Compiler.Compile(CompilationJob.CreateFromFiles(path));
result.Diagnostics.Should().NotContain(d => d.Severity == Diagnostic.DiagnosticSeverity.Error); ;
dialogue.Program = result.Program;
dialogue.NodeExists("Test").Should().BeTrue(); //<- fails
dialogue.NodeExists("Test ").Should().BeFalse(); //<- fails
}
This is more prevalent when adding comments to nodes ie:
title: Test // I introduced a space to the node title
---
===
What is the expected behavior?
The NodeTitle should be trimmed of spaces either when assigned during the Compile step or when lexing.
Please tell us about your environment
- Operating System: Windows 11 10.0.262
- Yarn Spinner Version: 3.2.7
- Extension Version:
- Unity Version: 6000.3.16f1
Other information
Potential fix:
Modifying YarnSpinner.Compiler\Compiler.cs 136
node.Node.NodeTitle = titleHeader.title?.Text; // from
node.Node.NodeTitle = titleHeader.title?.Text?.Trim(); // to
Alternatively, modifying the grammar to remove the WS? pre/postfix in HEADER_TITLE_ID (and put it in HEADER_TITLE_COMMENT or HEADER_TITLE_NEWLINE where the matched value is less consequential) or adding a custom lexer action to trim spaces may be cleaner.
Add tags
Core (compiler), Unity
What is the current behavior?
Node titles with trailing spaces include the space in the parsed node title. This contrasts with
TryGetNodeTitlethat trims the trailing space.Please provide the steps to reproduce, and if possible a minimal demo of the problem:
define a node with a trailing space after the title:
Query for its existence:
This is more prevalent when adding comments to nodes ie:
What is the expected behavior?
The NodeTitle should be trimmed of spaces either when assigned during the Compile step or when lexing.
Please tell us about your environment
Other information
Potential fix:
Modifying
YarnSpinner.Compiler\Compiler.cs 136Alternatively, modifying the grammar to remove the
WS?pre/postfix inHEADER_TITLE_ID(and put it inHEADER_TITLE_COMMENTorHEADER_TITLE_NEWLINEwhere the matched value is less consequential) or adding a custom lexer action to trim spaces may be cleaner.Add tags
Core (compiler), Unity