Skip to content

Add Jump to Tile Coordinates feature #4215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sirajahmadzai
Copy link

This PR implements the "Jump to location by tile coordinates" feature requested in issue #1367.

Changes:

  • Add TileLocatorSource for parsing tile coordinates
  • Add "Jump to Tile" action with Ctrl+Shift+G shortcut
  • Support multiple coordinate formats: x,y, x:10 y:20, 10 20, etc.
  • Update keyboard shortcuts documentation

Testing:

  • Created test applications to verify coordinate parsing
  • All supported formats work correctly
  • Invalid inputs are properly rejected

Files Changed:

  • src/tiled/tilelocator.h - New header file
  • src/tiled/tilelocator.cpp - New implementation
  • src/tiled/mainwindow.ui - Added action and menu item
  • src/tiled/mainwindow.h - Added method declaration
  • src/tiled/mainwindow.cpp - Added method implementation
  • src/tiled/libtilededitor.qbs - Added to build system
  • docs/manual/keyboard-shortcuts.rst - Updated documentation

Fixes #1367

- Implement TileLocatorSource for parsing tile coordinates
- Add 'Jump to Tile' action with Ctrl+Shift+G shortcut
- Support multiple coordinate formats: x,y, x:10 y:20, 10 20, etc.
- Update keyboard shortcuts documentation
- Fixes issue mapeditor#1367
@sirajahmadzai sirajahmadzai force-pushed the feature/jump-to-tile-coordinates branch from 08afd98 to 3e6b93e Compare July 19, 2025 05:20
@bjorn bjorn requested a review from Copilot July 19, 2025 06:59
Copy link

@Copilot 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 adds a "Jump to Tile Coordinates" feature that allows users to navigate directly to specific tile locations using keyboard input. The implementation provides a locator widget that accepts multiple coordinate formats and integrates with the existing locator system.

Key changes:

  • Implements TileLocatorSource for parsing and handling tile coordinate input
  • Adds jump to tile action with Ctrl+Shift+G keyboard shortcut
  • Supports multiple coordinate formats (x,y / x:10 y:20 / 10 20 / single numbers)

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/tiled/tilelocator.h New header defining TileLocatorSource class and Match structure
src/tiled/tilelocator.cpp Implementation of coordinate parsing, UI delegate, and navigation logic
src/tiled/mainwindow.ui Added Jump to Tile action and menu item with Ctrl+Shift+G shortcut
src/tiled/mainwindow.h Added jumpToTile method declaration
src/tiled/mainwindow.cpp Connected action to jumpToTile method implementation
src/tiled/libtilededitor.qbs Added new source files to build system
docs/manual/keyboard-shortcuts.rst Updated documentation with new keyboard shortcut

return true;
}

// Format 2: "x:10 y:20" or "x:10, y:20"
Copy link
Preview

Copilot AI Jul 19, 2025

Choose a reason for hiding this comment

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

The regular expression pattern is complex and hard to understand. Consider breaking it into smaller, more readable patterns or adding a comment explaining the expected format.

Suggested change
// Format 2: "x:10 y:20" or "x:10, y:20"
// Format 2: "x:10 y:20" or "x:10, y:20"
// Matches formats like "x:10 y:20" or "x:10, y:20".
// - "x:10" captures the x-coordinate.
// - "y:20" (optional) captures the y-coordinate, separated by a comma or whitespace.

Copilot uses AI. Check for mistakes.

Copy link
Author

Choose a reason for hiding this comment

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

@bjorn this is not a regular expression, it is a comment

Comment on lines +274 to +278
QString remaining = text.mid(match.capturedEnd());
QRegularExpression yPattern(QStringLiteral(R"(y\s*:\s*(\d+))"));
auto yMatch = yPattern.match(remaining);
if (yMatch.hasMatch()) {
tilePos.setY(yMatch.captured(1).toInt());
Copy link
Preview

Copilot AI Jul 19, 2025

Choose a reason for hiding this comment

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

[nitpick] The nested logic for handling partial x:y coordinate matches is complex and could be simplified. Consider extracting this into a separate helper method.

Suggested change
QString remaining = text.mid(match.capturedEnd());
QRegularExpression yPattern(QStringLiteral(R"(y\s*:\s*(\d+))"));
auto yMatch = yPattern.match(remaining);
if (yMatch.hasMatch()) {
tilePos.setY(yMatch.captured(1).toInt());
if (parseYCoordinateFromRemainingText(text.mid(match.capturedEnd()), tilePos)) {

Copilot uses AI. Check for mistakes.

Comment on lines +196 to +203
// Try to find any open map document
const auto documents = documentManager->documents();
for (auto document : documents) {
if (auto mapDoc = qobject_cast<MapDocument*>(document.data())) {
mapDocument = mapDoc;
break;
}
}
Copy link
Preview

Copilot AI Jul 19, 2025

Choose a reason for hiding this comment

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

[nitpick] The fallback logic for finding a map document when no current document exists could be extracted into a helper method to improve readability.

Suggested change
// Try to find any open map document
const auto documents = documentManager->documents();
for (auto document : documents) {
if (auto mapDoc = qobject_cast<MapDocument*>(document.data())) {
mapDocument = mapDoc;
break;
}
}
mapDocument = findFallbackMapDocument(documentManager);

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.

Jump to location by tile coordinates
1 participant