Merge fff84ab363
into a102b08743
This commit is contained in:
commit
df4dbe1b73
2 changed files with 16 additions and 7 deletions
|
@ -7,7 +7,11 @@ struct HelloWorld {}
|
|||
|
||||
impl Render for HelloWorld {
|
||||
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
|
||||
let text = "The longest word 你好世界这段是中文,こんにちはこの段落は日本語です in any of the major English language dictionaries is pneumonoultramicroscopicsilicovolcanoconiosis, a word that refers to a lung disease contracted from the inhalation of very fine silica particles, specifically from a volcano; medically, it is the same as silicosis.";
|
||||
let text = "The longest word 你好世界这段是中文,こんにちはこの段落は日本語です in any of the major \
|
||||
English language dictionaries is pneumonoultramicroscopicsilicovolcanoconiosis, a word that \
|
||||
refers to a lung disease contracted from the inhalation of very fine silica particles, \
|
||||
a url https://github.com/zed-industries/zed/pull/35724?query=foo&bar=2, \
|
||||
specifically from a volcano; medically, it is the same as silicosis.";
|
||||
div()
|
||||
.id("page")
|
||||
.size_full()
|
||||
|
|
|
@ -163,6 +163,8 @@ impl LineWrapper {
|
|||
line
|
||||
}
|
||||
|
||||
/// Any character in this list should be treated as a word character,
|
||||
/// meaning it can be part of a word that should not be wrapped.
|
||||
pub(crate) fn is_word_char(c: char) -> bool {
|
||||
// ASCII alphanumeric characters, for English, numbers: `Hello123`, etc.
|
||||
c.is_ascii_alphanumeric() ||
|
||||
|
@ -180,10 +182,9 @@ impl LineWrapper {
|
|||
// https://en.wikipedia.org/wiki/Cyrillic_script_in_Unicode
|
||||
matches!(c, '\u{0400}'..='\u{04FF}') ||
|
||||
// Some other known special characters that should be treated as word characters,
|
||||
// e.g. `a-b`, `var_name`, `I'm`, '@mention`, `#hashtag`, `100%`, `3.1415`, `2^3`, `a~b`, etc.
|
||||
matches!(c, '-' | '_' | '.' | '\'' | '$' | '%' | '@' | '#' | '^' | '~' | ',') ||
|
||||
// Characters that used in URL, e.g. `https://github.com/zed-industries/zed?a=1&b=2` for better wrapping a long URL.
|
||||
matches!(c, '/' | ':' | '?' | '&' | '=') ||
|
||||
// e.g. `a-b`, `var_name`, `I'm`, '@mention`, `#hashtag`, `100%`, `3.1415`,
|
||||
// `2^3`, `a~b`, `a=1`, `Self::new`, etc.
|
||||
matches!(c, '-' | '_' | '.' | '\'' | '$' | '%' | '@' | '#' | '^' | '~' | ',' | '=' | ':') ||
|
||||
// `⋯` character is special used in Zed, to keep this at the end of the line.
|
||||
matches!(c, '⋯')
|
||||
}
|
||||
|
@ -648,15 +649,19 @@ mod tests {
|
|||
assert_word("@mention");
|
||||
assert_word("#hashtag");
|
||||
assert_word("$variable");
|
||||
assert_word("a=1");
|
||||
assert_word("Self::is_word_char");
|
||||
assert_word("more⋯");
|
||||
|
||||
// Space
|
||||
assert_not_word("foo bar");
|
||||
|
||||
// URL case
|
||||
assert_word("https://github.com/zed-industries/zed/");
|
||||
assert_word("github.com");
|
||||
assert_word("a=1&b=2");
|
||||
assert_not_word("zed-industries/zed");
|
||||
assert_not_word("zed-industries\\zed");
|
||||
assert_not_word("a=1&b=2");
|
||||
assert_not_word("foo?b=2");
|
||||
|
||||
// Latin-1 Supplement
|
||||
assert_word("ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue