Merge pull request #55 from Demonthos/fix_single_line_rsx_hot_reloading

fix single line rsx hot reloading
This commit is contained in:
YuKun Liu 2022-07-14 21:30:11 +08:00 committed by GitHub
commit 66862e2310
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View file

@ -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 {

View file

@ -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 {