Skip to content

Added grep / full-text search across decompiled source, along with text highlighting for the grep results#117

Open
00x127 wants to merge 2 commits into
FabricMC:mainfrom
00x127:feature/grep-search
Open

Added grep / full-text search across decompiled source, along with text highlighting for the grep results#117
00x127 wants to merge 2 commits into
FabricMC:mainfrom
00x127:feature/grep-search

Conversation

@00x127

@00x127 00x127 commented Apr 21, 2026

Copy link
Copy Markdown

No description provided.

@deirn

deirn commented Apr 21, 2026

Copy link
Copy Markdown
Member

Can you explain how it works?

@00x127

00x127 commented Apr 21, 2026

Copy link
Copy Markdown
Author

Can you explain how it works?

lets say you want to find all instances of the word "particle" inside the decompiled source code.

youd go over to the new grep tab and search it, then it will show you all instances of where the word is used.

example

Comment thread src/ui/GrepPanel.tsx
onClick={() => handleResultClick(match.className)}
style={{ cursor: 'pointer', padding: '2px 8px', fontSize: '12px', borderRadius: '4px', transition: 'background-color 0.15s' }}
onMouseEnter={e => e.currentTarget.style.backgroundColor = 'rgba(255,255,255,0.1)'}
onMouseLeave={e => e.currentTarget.style.backgroundColor = 'transparent'}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shouldn't this be done using a CSS hover selector instead?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nvm, this seems to just be a react thing. Weird framework :/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree that using CSS would've been better.

Comment thread src/logic/GrepSearch.ts
let scanned = 0;

for (let i = 0; i < classNames.length; i += SCAN_BATCH) {
if (cancelFlag) break;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Instead of having some global flag for cancellation, is there a way we could use something like AbortController?
It might also allow us to use Promise.all here too instead of a manual setTimeout

@deirn

deirn commented Apr 21, 2026

Copy link
Copy Markdown
Member

How's the performance? I've tried some JS libraries to do this, and they are quite slow.

@00x127

00x127 commented Apr 21, 2026

Copy link
Copy Markdown
Author

How's the performance? I've tried some JS libraries to do this, and they are quite slow.

i've made it read raw bytes from each class file and scan the Java constant pool directly

this is pure JS, takes ~1ms per class, and doesnt touch the decompile workers at all

so in other words, its pretty fast

@CelDaemon

CelDaemon commented Apr 21, 2026

Copy link
Copy Markdown

Not fast enough to prevent my browser from freezing after it starts decompiling apparently.

EDIT: Worked the second time?

Also, seems like clicking on a match does take you to the right file, but not the right line.

@deirn

deirn commented Apr 21, 2026

Copy link
Copy Markdown
Member

this is pure JS, takes ~1ms per class, and doesnt touch the decompile workers at all

Hm, it does decompile the classes though?
https://github.com/FabricMC/mcsrc/pull/117/changes#diff-5ffed2a098a625d5af1ef529c9e15b4b0f44e18e08938d94c928e562818dbd1cR143

@CelDaemon

CelDaemon commented Apr 21, 2026

Copy link
Copy Markdown

Hm, it does decompile the classes though?

It only decompiles classes with matches, which is at least better than decompiling every class.
The decomp does take a lot longer than 1ms per class though, at least on my system.

@00x127

00x127 commented Apr 21, 2026

Copy link
Copy Markdown
Author

Hm, it does decompile the classes though?

It only decompiles classes with matches, which is at least better than decompiling every class. The decomp does take a lot longer than 1ms per class though, at least on my system.

odd, sticks around to 1ms for me
its already really fast but if you have any ideas on how to improve what im doing, lmk

@deirn

deirn commented Apr 21, 2026

Copy link
Copy Markdown
Member

Did you try with the IndexedDB cleared? Otherwise it will use the cached result.

@00x127

00x127 commented Apr 21, 2026

Copy link
Copy Markdown
Author

Did you try with the IndexedDB cleared? Otherwise it will use the cached result.

i did

@CelDaemon

Copy link
Copy Markdown

It might just be my system tbh, I'd say don't worry about too much unless others experience the same

@00x127

00x127 commented May 13, 2026

Copy link
Copy Markdown
Author

How come this hasn't been merged yet?

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.

3 participants