fix single line rsx hot reloading

This commit is contained in:
Evan Almloff committed 2022-07-14 07:38:51 -05:00
1 parent 7929dd4c52
commit 6c11eca05b
2 files changed
+12

No files matched your search

+6
View File
@@ -113,8 +113,14 @@ pub async fn hot_reload_handler(
*first = first.split_at(start.column).1; *first = first.split_at(start.column).1;
} }
if let Some(last) = lines.last_mut() { if let Some(last) = lines.last_mut() {
// 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; *last = last.split_at(end.column).0;
} }
}
let rsx = lines.join("\n"); let rsx = lines.join("\n");
messages.push(SetRsxMessage { messages.push(SetRsxMessage {
location: hr, location: hr,
+6
View File
@@ -137,8 +137,14 @@ pub async fn startup_hot_reload(config: CrateConfig) -> Result<()> {
*first = first.split_at(start.column).1; *first = first.split_at(start.column).1;
} }
if let Some(last) = lines.last_mut() { if let Some(last) = lines.last_mut() {
// 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; *last = last.split_at(end.column).0;
} }
}
let rsx = lines.join("\n"); let rsx = lines.join("\n");
messages.push(SetRsxMessage { messages.push(SetRsxMessage {
location: hr, location: hr,