Skip to content

Integrate Search Results with Monaco Editor Navigation#9

Open
rachit-goyal1071 wants to merge 3 commits intoankurg132:mainfrom
rachit-goyal1071:main
Open

Integrate Search Results with Monaco Editor Navigation#9
rachit-goyal1071 wants to merge 3 commits intoankurg132:mainfrom
rachit-goyal1071:main

Conversation

@rachit-goyal1071
Copy link
Copy Markdown
Contributor

Integrate Search Results with Monaco Editor Navigation

Related Issue

Closes / Addresses: #7


Summary

This PR adds editor-side integration between the global search feature and flutter_monaco, making search results actionable inside the editor.

It aligns search behavior with standard IDE expectations by ensuring that interacting with a search result correctly navigates, reveals, highlights, and focuses the Monaco editor.


What This PR Covers

Navigate to Match

  • Move the editor cursor to the correct line and column when a search result is selected
  • Open the target file if it is not already active

Reveal Match in Viewport

  • Scroll the editor so the matched line is visible
  • Avoid cases where navigation occurs but the match remains off-screen

Highlight Matched Range

  • Apply selection or decoration to visually emphasize the matched text
  • Clear or update highlights when a different result is selected

Editor Focus Handling

  • Transfer keyboard focus to the editor after clicking a search result
  • Enable immediate typing or navigation after jump

Third-Party Monaco Patch

This PR introduces a small third-party / patched Monaco layer to bridge gaps in the
current flutter_monaco API.

Why this is needed

The public flutter_monaco APIs do not fully expose:

  • Precise cursor and range navigation
  • Reliable reveal / scroll-to-range behavior
  • Decoration lifecycle management for search highlights
  • Consistent editor focus handling across platforms

These capabilities are required to make search results fully actionable and
IDE-consistent.

What the patch does

  • Exposes missing Monaco editor methods required for search navigation
  • Provides stable highlight and decoration management
  • Ensures reliable editor focus after navigation events

Future direction

This layer is intentionally minimal and isolated. If flutter_monaco adds
equivalent APIs upstream, this patch can be removed or simplified.


Implementation Notes

  • Uses flutter_monaco controller APIs where available
  • Falls back to patched Monaco APIs when required for:
    • Cursor positioning
    • Reveal / scrolling
    • Highlight lifecycle handling
  • Keeps Monaco-specific logic isolated from search UI and indexing code

Scope Clarification

  • This PR is limited to editor-side behavior:
    • Navigation
    • Scrolling / reveal
    • Highlighting
    • Focus handling
  • Search indexing, result generation, and ranking are out of scope

Context

This PR is raised following discussion in issue #7.
The prior conversation is referenced only for background and does not affect the
implementation scope.

@rachit-goyal1071
Copy link
Copy Markdown
Contributor Author

Hey @ankurg132 is there any update on PR any changes required or any othr issue is there please do tell me..

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.

1 participant