Skip to content

Commit

Permalink
Merge pull request #55 from Demonthos/fix_single_line_rsx_hot_reloading
Browse files Browse the repository at this point in the history
fix single line rsx hot reloading
  • Loading branch information
mrxiaozhuox authored Jul 14, 2022
2 parents 4bb8015 + 6c11eca commit 66862e2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/server/hot_reload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,13 @@ pub async fn hot_reload_handler(
*first = first.split_at(start.column).1;
}
if let Some(last) = lines.last_mut() {
*last = last.split_at(end.column).0;
// if there is only one line the start index of last line will be the start of the rsx!, not the start of the line
if start.line == end.line {
*last =
last.split_at(end.column - start.column).0;
} else {
*last = last.split_at(end.column).0;
}
}
let rsx = lines.join("\n");
messages.push(SetRsxMessage {
Expand Down
8 changes: 7 additions & 1 deletion src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,13 @@ pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> {
*first = first.split_at(start.column).1;
}
if let Some(last) = lines.last_mut() {
*last = last.split_at(end.column).0;
// if there is only one line the start index of last line will be the start of the rsx!, not the start of the line
if start.line == end.line {
*last =
last.split_at(end.column - start.column).0;
} else {
*last = last.split_at(end.column).0;
}
}
let rsx = lines.join("\n");
messages.push(SetRsxMessage {
Expand Down

0 comments on commit 66862e2

Please sign in to comment.