Skip to content

begin <= end (12 <= 6) when slicing #10

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

Open
webxxxxx opened this issue Apr 1, 2024 · 2 comments
Open

begin <= end (12 <= 6) when slicing #10

webxxxxx opened this issue Apr 1, 2024 · 2 comments

Comments

@webxxxxx
Copy link

webxxxxx commented Apr 1, 2024

fn highlight(snippet: Snippet) -> String {
let mut result = String::new();
let mut start_from = 0;

for fragment_range in snippet.highlighted() {
    result.push_str(&snippet.fragment()[**start_from..fragment_range.start**]);
    result.push_str("<font color='red'>");
    result.push_str(&snippet.fragment()[fragment_range.clone()]);
    result.push_str("</font>");
    start_from = fragment_range.end;
}

result.push_str(&snippet.fragment()[start_from..]);
result

}

@webxxxxx
Copy link
Author

webxxxxx commented Apr 1, 2024

对以下文本内容搜索 “滚动条到底部” 可以重现问题


判断滚动条到底部,需要用到DOM的三个属性值,即scrollTop、clientHeight、scrollHeight。
scrollTop为滚动条在Y轴上的滚动距离。

clientHeight为内容可视区域的高度。

scrollHeight为内容可视区域的高度加上溢出(滚动)的距离。

从这个三个属性的介绍就可以看出来,滚动条到底部的条件即为scrollTop + clientHeight == scrollHeight。(兼容不同的浏览器)。

@webxxxxx webxxxxx changed the title begin <= end (45 <= 39) snippet.highlighted begin <= end (12 <= 6) when slicing Apr 1, 2024
@jiegec
Copy link
Owner

jiegec commented Apr 1, 2024

I think the code come from somewhere else. Can you provide a code using tantity_jieba to reveal the bug?

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

No branches or pull requests

2 participants