Skip to content
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

Correctly view non-text files in single file window and Open Quickly #1820

Conversation

plbstl
Copy link
Contributor

@plbstl plbstl commented Jul 23, 2024

Description

This PR extends CodeEdit's preview functionality to files viewed in single file window and Open Quickly.

Related Issues

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code

Screenshots

BEFORE:

before-sfm icon

before-sfm gif

before-open.quickly.mov

AFTER:

after-sfm icon

after-sfm.gif.mov
after-open.quickly.mov

plbstl added 4 commits July 23, 2024 02:51
Use `dismantleNSView` in `AnyFileView` to prevent crashes when using Open Quickly.
What crashes?
1. When using Open Quickly without the workaround in `AnyFileView`, search for a media file (.png, .gif, .mp4, etc)
2. Press escape to close Open Quickly
3. re-open Open Quickly. The media preview is gone
4. Attempt to navigate upwards or downwards using the arrow buttons
5. A crash occurs (QuickLook is attempting to reuse an already closed preview)
@austincondiff
Copy link
Collaborator

Could you please include a screenshot or screen recording demonstrating this functionality?

allow files with a utType that is neither image nor PDF to be previewed (CodeEditApp#1822)
@plbstl
Copy link
Contributor Author

plbstl commented Aug 19, 2024

I've updated the PR description with the visuals for before and after changes.

@plbstl
Copy link
Contributor Author

plbstl commented Aug 19, 2024

This gets shown in the issues tab when the main branch was merged in. This also happens in the main branch

main branch issue

Perhaps, a simple if check for negative values can help.

let frameHeight = constrainedHeight - totalFontHeight + 1

.frame(height: frameHeight >= 0 ? frameHeight : 0)

@austincondiff
Copy link
Collaborator

Or you could use min...

.frame(height: min(0, constrainedHeight - totalFontHeight + 1))

Copy link
Collaborator

@austincondiff austincondiff left a comment

Choose a reason for hiding this comment

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

LGTM

@austincondiff austincondiff merged commit 2e4bec8 into CodeEditApp:main Aug 21, 2024
2 checks passed
@thecoolwinter thecoolwinter added the enhancement New feature or request label Aug 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐞 Binary files are previewed as text files in Open Quickly and single file window
4 participants