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

Whole word scanning #1330

Merged
merged 13 commits into from
Aug 24, 2024
Merged

Whole word scanning #1330

merged 13 commits into from
Aug 24, 2024

Conversation

jamesmaa
Copy link
Collaborator

@jamesmaa jamesmaa commented Aug 21, 2024

Fixes #889

  • : Popup flickers when moving within characters in a word, probably because yomitan considers the lookups to be different
  • : Doesn't work on google.com apparently according to @Casheeew

@Casheeew Casheeew marked this pull request as ready for review August 22, 2024 09:25
@Casheeew Casheeew requested a review from a team as a code owner August 22, 2024 09:25
@Casheeew Casheeew marked this pull request as draft August 22, 2024 10:25
@Kuuuube Kuuuube added kind/enhancement The issue or PR is a new feature or request area/ui-ux The issue or PR is related to UI/UX/Design labels Aug 22, 2024
ext/js/background/backend.js Outdated Show resolved Hide resolved
ext/js/dom/text-source-generator.js Outdated Show resolved Hide resolved
types/ext/dom-text-scanner.d.ts Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Aug 22, 2024

⚠️ Visual differences introduced by this PR; please validate if they are desirable.

View Playwright Report (note: open the "playwright-report" artifact)

@jamesmaa jamesmaa marked this pull request as ready for review August 22, 2024 17:51
Copy link
Member

@Kuuuube Kuuuube left a comment

Choose a reason for hiding this comment

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

Is there any upper bound for how long a word is/how far backwards it can seek? I'm not seeing anything and this could lead to quite a lot of trouble if a user tries to scan an enormous string. Even a huge limit like 1000 characters would probably be a good idea.

@jamesmaa
Copy link
Collaborator Author

@Kuuuube it uses this._scanLength as the max limit for looking back. Basically it tells yomitan to try to set the startOffset back by this._scanLength characters and indicates for it to stop going back if it sees a whitespace.

Reference
https://github.com/themoeway/yomitan/pull/1330/files#diff-255481c4f025ab785ed8746ef13607c1fcf4ad6fc4e7ee7aecd69a25244bf992R474

Copy link
Member

@Kuuuube Kuuuube left a comment

Choose a reason for hiding this comment

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

Looks good, will approve when tests are fixed. test/options-util.test.js needs the version bumped from 50 to 51.

@jamesmaa jamesmaa requested a review from Kuuuube August 22, 2024 18:52
Kuuuube
Kuuuube previously approved these changes Aug 22, 2024
@StefanVukovic99
Copy link
Member

Words in quotes might not be scannable. Also not sure why the first word in the example here can't be scanned:
Screencast from 08-22-2024 09:13:40 PM.webm

Probably seeking back into other HTML elements and concatenating. Layout-aware scanning doesn't seem to impact it.

@Kuuuube
Copy link
Member

Kuuuube commented Aug 22, 2024

Might want to have it pull the sentence termination characters and break on any of them. Though there is also the issue of should it stop on ' because some words contain ' but it could also be used to quote things.

@Casheeew
Copy link
Collaborator

Probably seeking back into other HTML elements and concatenating. Layout-aware scanning doesn't seem to impact it.

Might be the same or similar issue to what i demonstrated on discord.

@Casheeew
Copy link
Collaborator

Casheeew commented Aug 22, 2024

Might want to have it pull the sentence termination characters and break on any of them. Though there is also the issue of should it stop on ' because some words contain ' but it could also be used to quote things.

I think it's safe to just look one character before the quote and break if it's a whitespace, and not otherwise.

Or rather, look for a whitespace and any combination of quotes, to accommodate the case if the string is doubly quoted.

@jamesmaa jamesmaa requested a review from Kuuuube August 23, 2024 16:57
@Casheeew
Copy link
Collaborator

It now works on double quoted words but not on single quoted words.

@Casheeew
Copy link
Collaborator

Otherwise lgtm

@jamesmaa
Copy link
Collaborator Author

Okay done I followed your advice and peeked at the character before the single quotes to see if it's an apostrophe or wrapped in single quotes

@jamesmaa jamesmaa added this pull request to the merge queue Aug 24, 2024
Merged via the queue into themoeway:master with commit e7bab2c Aug 24, 2024
12 checks passed
@jamesmaa jamesmaa deleted the whole-word branch August 24, 2024 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ui-ux The issue or PR is related to UI/UX/Design kind/enhancement The issue or PR is a new feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support option to tap to scan whole word
4 participants