From 8f133b2de936a0c312c9ce84e44e507b0277c1c3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Feb 2026 09:06:57 +0000 Subject: [PATCH 1/3] Initial plan From 262b2754aa9882df74474e6c6c15adda32dd56d4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Feb 2026 09:10:38 +0000 Subject: [PATCH 2/3] Fix AttributedScopeStack.Equals logic Co-authored-by: danipen <501613+danipen@users.noreply.github.com> --- .../Grammars/AttributedScopeStackTests.cs | 35 +++++++++++++++++++ .../Internal/Grammars/AttributedScopeStack.cs | 4 +-- 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 src/TextMateSharp.Tests/Internal/Grammars/AttributedScopeStackTests.cs diff --git a/src/TextMateSharp.Tests/Internal/Grammars/AttributedScopeStackTests.cs b/src/TextMateSharp.Tests/Internal/Grammars/AttributedScopeStackTests.cs new file mode 100644 index 0000000..85c7453 --- /dev/null +++ b/src/TextMateSharp.Tests/Internal/Grammars/AttributedScopeStackTests.cs @@ -0,0 +1,35 @@ +using NUnit.Framework; +using TextMateSharp.Internal.Grammars; + +namespace TextMateSharp.Tests.Internal.Grammars +{ + [TestFixture] + internal class AttributedScopeStackTests + { + [Test] + public void Equals_ShouldMatchEquivalentStacks() + { + AttributedScopeStack stack1 = new AttributedScopeStack(new AttributedScopeStack(null, "source.cs", 1), "meta.test", 2); + AttributedScopeStack stack2 = new AttributedScopeStack(new AttributedScopeStack(null, "source.cs", 1), "meta.test", 2); + + Assert.IsTrue(stack1.Equals(stack2)); + Assert.IsTrue(stack2.Equals(stack1)); + } + + [Test] + public void Equals_ShouldReturnFalseForDifferentType() + { + AttributedScopeStack stack = new AttributedScopeStack(null, "source.cs", 1); + + Assert.IsFalse(stack.Equals(42)); + } + + [Test] + public void Equals_ShouldReturnFalseForNull() + { + AttributedScopeStack stack = new AttributedScopeStack(null, "source.cs", 1); + + Assert.IsFalse(stack.Equals(null)); + } + } +} diff --git a/src/TextMateSharp/Internal/Grammars/AttributedScopeStack.cs b/src/TextMateSharp/Internal/Grammars/AttributedScopeStack.cs index c79ffe8..70ab106 100644 --- a/src/TextMateSharp/Internal/Grammars/AttributedScopeStack.cs +++ b/src/TextMateSharp/Internal/Grammars/AttributedScopeStack.cs @@ -66,7 +66,7 @@ private static bool Equals(AttributedScopeStack a, AttributedScopeStack b) public override bool Equals(object other) { - if (other == null || (other is AttributedScopeStack)) + if (other == null || !(other is AttributedScopeStack)) return false; return Equals(this, (AttributedScopeStack)other); @@ -206,4 +206,4 @@ private static List GenerateScopes(AttributedScopeStack scopesList) return result; } } -} \ No newline at end of file +} From 3574b27772a16ff5c441f387d1640f638ea57975 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Feb 2026 09:11:09 +0000 Subject: [PATCH 3/3] Add negative AttributedScopeStack equality test Co-authored-by: danipen <501613+danipen@users.noreply.github.com> --- .../Internal/Grammars/AttributedScopeStackTests.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/TextMateSharp.Tests/Internal/Grammars/AttributedScopeStackTests.cs b/src/TextMateSharp.Tests/Internal/Grammars/AttributedScopeStackTests.cs index 85c7453..590933d 100644 --- a/src/TextMateSharp.Tests/Internal/Grammars/AttributedScopeStackTests.cs +++ b/src/TextMateSharp.Tests/Internal/Grammars/AttributedScopeStackTests.cs @@ -16,6 +16,16 @@ public void Equals_ShouldMatchEquivalentStacks() Assert.IsTrue(stack2.Equals(stack1)); } + [Test] + public void Equals_ShouldReturnFalseForDifferentStacks() + { + AttributedScopeStack stack1 = new AttributedScopeStack(new AttributedScopeStack(null, "source.cs", 1), "meta.test", 2); + AttributedScopeStack stack2 = new AttributedScopeStack(new AttributedScopeStack(null, "source.cs", 1), "meta.other", 2); + + Assert.IsFalse(stack1.Equals(stack2)); + Assert.IsFalse(stack2.Equals(stack1)); + } + [Test] public void Equals_ShouldReturnFalseForDifferentType() {