Skip to content

Bug: first Tab after Shift+Tab sometimes does nothing in ted #140

@YourRobotOverlord

Description

@YourRobotOverlord

Summary

When using the ted example app, indenting a line with Tab, then unindenting with Shift+Tab, can leave the next Tab keypress ignored. The following Tab keypress then indents the line normally.

Repro

  1. create a line of text: hello world
  2. position cursor at start of line
  3. press tab; line indents correctly
  4. press shift+tab; line unindents correctly
  5. press tab; line does not indent
  6. press tab a second time; line indents correctly

Expected

The first Tab after Shift+Tab should indent the line immediately.

Actual

The first Tab after Shift+Tab is swallowed, and only the second Tab indents the line.

Notes

  • This has been observed in the examples\ted app.
  • I added candidate repro tests that should fail if the bug were reproduced in the current test harness, but both pass:
[Fact]
public async Task Tab_After_ShiftTab_Reindents_Line_On_First_Keypress ()
{
    await using AppFixture<EditorTestHost> fx = new (() => new ("hello world"));
    fx.Top.Editor.SetFocus ();
    fx.Top.Editor.CaretOffset = 0;

    fx.Injector.InjectKey (Key.Tab, Direct);

    Assert.Equal ("\thello world", fx.Top.Editor.Document!.Text);
    Assert.Equal (1, fx.Top.Editor.CaretOffset);

    fx.Injector.InjectKey (Key.Tab.WithShift, Direct);

    Assert.Equal ("hello world", fx.Top.Editor.Document.Text);
    Assert.Equal (0, fx.Top.Editor.CaretOffset);

    fx.Injector.InjectKey (Key.Tab, Direct);

    Assert.Equal ("\thello world", fx.Top.Editor.Document.Text);
    Assert.Equal (1, fx.Top.Editor.CaretOffset);
}
[Fact]
public async Task Editor_Tab_After_ShiftTab_Reindents_On_First_Keypress ()
{
    await using AppFixture<TedApp> fx = new (() => new TedApp ());
    InputInjectionOptions options = new ();
    fx.Top.Editor.SetFocus ();
    fx.Top.Editor.Document!.Text = "hello world";
    fx.Top.Editor.CaretOffset = 0;

    fx.Injector.InjectKey (Key.Tab, options);

    Assert.Equal ("    hello world", fx.Top.Editor.Document.Text);
    Assert.Equal (4, fx.Top.Editor.CaretOffset);

    fx.Injector.InjectKey (Key.Tab.WithShift, options);

    Assert.Equal ("hello world", fx.Top.Editor.Document.Text);
    Assert.Equal (0, fx.Top.Editor.CaretOffset);

    fx.Injector.InjectKey (Key.Tab, options);

    Assert.Equal ("    hello world", fx.Top.Editor.Document.Text);
    Assert.Equal (4, fx.Top.Editor.CaretOffset);
}
  • The Editor-only integration repro passes under direct ANSI test input.
  • The TedApp integration repro also passes under the current harness, including the non-Direct default input injection path.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions