Skip to content

Conversation

@whitphx
Copy link
Owner

@whitphx whitphx commented Oct 25, 2025

No description provided.

Copilot AI review requested due to automatic review settings October 25, 2025 16:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements the cycle-spacing command, which provides Emacs-style whitespace cycling functionality. The command cycles through three states when invoked repeatedly: replacing multiple spaces/tabs with a single space, deleting all whitespace, and restoring the original spacing.

Key Changes:

  • Implements core CycleSpacing command class with state management and interruption handling
  • Adds comprehensive test coverage for various scenarios including multi-cursor support, tabs, mixed whitespace, and edge cases
  • Registers command bindings across multiple keybinding configurations

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/commands/edit.ts Implements the CycleSpacing command class with cycling logic, state management, and cursor positioning
src/emulator.ts Registers the CycleSpacing command in the emulator's command list
src/extension.ts Binds the cycleSpacing command to make it available as a VS Code command
package.json Adds keybindings for the cycleSpacing command across different meta prefix configurations
keybindings/move-edit.json Adds the base keybinding entry for cycleSpacing using meta+space
src/test/suite/commands/edit.cycle-spacing.test.ts Comprehensive test suite covering basic cycling, multi-cursor, tabs, interruption handling, and edge cases

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +112 to +119
let from = cursorChar;
while (from > 0) {
const char = lineText[from - 1];
if (char !== " " && char !== "\t") {
break;
}
from -= 1;
}
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whitespace detection logic is duplicated in two while loops. Consider extracting this into a helper function like isWhitespace(char: string): boolean to improve maintainability and make the code more DRY.

Copilot uses AI. Check for mistakes.
const newPos = new vscode.Position(line, original.from + original.before.length);
return new Selection(newPos, newPos);
}
}
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fallback case returns the current selection unchanged, but it's unclear when this would be reached since all three states (0, 1, 2) are explicitly handled. Consider adding a comment explaining when this fallback occurs or refactoring to make the logic clearer.

Suggested change
}
}
// This fallback should never be reached because all three states (0, 1, 2) are explicitly handled above.
// If reached, it indicates an unexpected state; returning the current selection unchanged as a safeguard.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants