Skip to content

Commit

Permalink
Minor bugfixes for channel link parsing and chat tab state handling (#97
Browse files Browse the repository at this point in the history
)
  • Loading branch information
TicClick authored Feb 20, 2024
1 parent 7450586 commit 7d20eda
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/steel_core/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/steel_core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "steel_core"
version = "0.1.4"
version = "0.1.5"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
13 changes: 8 additions & 5 deletions crates/steel_core/src/chat/links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,16 @@ impl Message {
// Channel name.
if i < bs.len() && bs[i] == b'#' {
i += 1;
while i < bs.len() && b'a' <= bs[i] && bs[i] <= b'z' {
while i < bs.len() && ((b'a' <= bs[i] && bs[i] <= b'z') || bs[i] == b'_') {
i += 1;
}
links.push(LinkLocation::Raw {
pos: (start, i),
protocol: LinkType::Channel,
});
// '#' is an invalid channel name -- skip it.
if i > start + 1 {
links.push(LinkLocation::Raw {
pos: (start, i),
protocol: LinkType::Channel,
});
}
continue;
}

Expand Down
4 changes: 2 additions & 2 deletions src/gui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ impl DecoratedText for &str {
}

pub fn validate_username(input: &str) -> Result<(), &'static str> {
match input.contains(|ch: char| !ch.is_ascii_alphanumeric() && !"-_ []".contains(ch)) {
match input.contains(|ch: char| !(ch.is_ascii_alphanumeric() || "-_ []@".contains(ch))) {
true => Err("invalid username"),
false => Ok(()),
}
}

pub fn validate_channel_name(input: &str) -> Result<(), &'static str> {
match input.contains(|ch: char| !ch.is_ascii_alphanumeric() && ch != '#') {
match input.contains(|ch: char| !(ch.is_ascii_alphanumeric() || ch == '#' || ch == '_')) {
true => Err("invalid channel name"),
false => Ok(()),
}
Expand Down
4 changes: 2 additions & 2 deletions src/gui/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ impl ApplicationWindow {
}

UIMessageIn::ChatSwitchRequested(name, message_id) => {
let lowercase_name = name.to_lowercase();
self.s.highlights.mark_as_read(&lowercase_name);
if self.s.has_chat(&name) {
let lowercase_name = name.to_lowercase();
self.s.highlights.mark_as_read(&lowercase_name);
self.s.active_chat_tab_name = lowercase_name;
if message_id.is_some() {
self.chat.scroll_to = message_id;
Expand Down

0 comments on commit 7d20eda

Please sign in to comment.