-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Fix find widget alignment #5741
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
Conversation
✅ Deploy Preview for continuedev canceled.
|
|
||
// Triggers that should cause results to temporarily disappear and then reload | ||
// Active = LLM is generating, etc. | ||
const active = useAppSelector((state) => state.session.isStreaming); | ||
|
||
useEffect(() => { | ||
if (active || isResizing) setMatches([]); | ||
else refreshSearch("none"); | ||
}, [refreshSearch, active]); | ||
else setTimeout(() => refreshSearch("none"), 300); // this gives plenty of time for resizing to finish |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After a delay for codeblocks etc to render, recalculate search
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will occasionally cause flake. Why is the timeout needed?
rect.top + | ||
searchContainer.clientTop + | ||
searchContainer.scrollTop - | ||
headerHeight; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the main fix - account for header height in result y offset
…allin/find-widget-alignment
}; | ||
}, [searchRef.current]); | ||
}, [searchRef, headerRef]); | ||
|
||
// Main function for finding matches and generating highlight overlays | ||
const refreshSearch = useCallback( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refreshSearch
is large and complicated as is and useFindWidget
is 500 lines long. How about moving this function of FindWidget
body?
const refreshSearch = useCallback( | |
const refreshSearch = useCallback(someNewFunction({ | |
headerRef, | |
searchRef, | |
debouncedInput, | |
scrollToMatch, | |
caseSensitive, | |
useRegex, | |
}, | |
[ | |
headerRef, | |
searchRef, | |
debouncedInput, | |
scrollToMatch, | |
caseSensitive, | |
useRegex, | |
...dependencies, | |
], | |
) |
@tomasz-stefaniak the issue is with alignment of results, not the widget itself. |
…allin/find-widget-alignment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for splitting up the code into smaller chunks!
Fixes find widget match alignment issues caused by tabs by giving the tabs a ref and then passing it to the find widget to account for its height when calculating positions.