Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 27 additions & 6 deletions src/XTerm.NET.Tests/OscPassthroughTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,40 @@ private Terminal CreateTerminal(int cols = 80, int rows = 24)
[Fact]
public void OscReceived_FiresForUnknownSequence()
{
// The reason this event exists: OSC 133 is the shell-integration code this terminal has no
// case for, and before this it reached Debug.WriteLine and was unrecoverable.
// The reason this event exists: a code with no case here reaches Debug.WriteLine and is
// otherwise unrecoverable. OSC 1337 is iTerm2's proprietary space, which this terminal does
// not implement and has no plans to.
//
// This used to use OSC 133, which was unimplemented when the event was added and is not any
// more. That is the Recognized contract working rather than a test going stale: a listener
// filling the gap stops doing so on its own once a code lands in HandleOsc. The pair below
// pins both halves of it.
var terminal = CreateTerminal();
var seen = Capture(terminal);

terminal.Write("\x1B]1337;SetMark\x07");

var osc = Assert.Single(seen);
Assert.Equal(1337, osc.Code);
Assert.Equal("1337", osc.Identifier);
Assert.Equal("SetMark", osc.Data);
Assert.Equal("1337;SetMark", osc.Raw);
Assert.False(osc.Recognized, "the terminal has no handler for 1337, which is the point");
}

[Fact]
public void OscReceived_ReportsShellIntegrationAsRecognized_NowThatItIsImplemented()
{
// The other half: OSC 133 is handled now, so a listener that only wants what this terminal
// ignores must be told to leave it alone.
var terminal = CreateTerminal();
var seen = Capture(terminal);

terminal.Write("\x1B]133;A\x07");

var osc = Assert.Single(seen);
Assert.Equal(133, osc.Code);
Assert.Equal("133", osc.Identifier);
Assert.Equal("A", osc.Data);
Assert.Equal("133;A", osc.Raw);
Assert.False(osc.Recognized, "the terminal has no handler for 133, which is the point");
Assert.True(osc.Recognized, "133 reaches a handler now, and Recognized has to say so");
}

[Fact]
Expand Down
Loading
Loading