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

Minor bugfixes for channel link parsing and chat tab state handling #97

Merged
merged 4 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading