Backport #893 and #903 to Rojo 7.4 (#946)

As part of prep for a 7.4.2 release, this backports changes to the 7.4.X
branch that we can reasonably ship in 7.4.2 without too many code
changes.
This commit is contained in:
Micah
2024-07-22 11:55:28 -07:00
committed by GitHub
parent c6ceaa5c87
commit 3b721242c1
4 changed files with 30 additions and 2 deletions

View File

@@ -1,6 +1,11 @@
# Rojo Changelog
## Unreleased Changes
* Added Never option to Confirmation ([#893])
* Fixed removing trailing newlines ([#903])
[#893]: https://github.com/rojo-rbx/rojo/pull/893
[#903]: https://github.com/rojo-rbx/rojo/pull/903
## [7.4.1] - February 20, 2024
* Made the `name` field optional on project files ([#870])

View File

@@ -300,7 +300,7 @@ impl Vfs {
let path = path.as_ref();
let contents = self.inner.lock().unwrap().read_to_string(path)?;
Ok(contents.lines().collect::<Vec<&str>>().join("\n").into())
Ok(contents.replace("\r\n", "\n").into())
}
/// Write a file to the VFS and the underlying backend.
@@ -473,3 +473,23 @@ impl VfsLock<'_> {
self.inner.commit_event(event)
}
}
#[cfg(test)]
mod test {
use crate::{InMemoryFs, Vfs, VfsSnapshot};
/// https://github.com/rojo-rbx/rojo/issues/899
#[test]
fn read_to_string_lf_normalized_keeps_trailing_newline() {
let mut imfs = InMemoryFs::new();
imfs.load_snapshot("test", VfsSnapshot::file("bar\r\nfoo\r\n\r\n"))
.unwrap();
let vfs = Vfs::new(imfs);
assert_eq!(
vfs.read_to_string_lf_normalized("test").unwrap().as_str(),
"bar\nfoo\n\n"
);
}
}

View File

@@ -26,7 +26,7 @@ local function invertTbl(tbl)
end
local invertedLevels = invertTbl(Log.Level)
local confirmationBehaviors = { "Initial", "Always", "Large Changes", "Unlisted PlaceId" }
local confirmationBehaviors = { "Initial", "Always", "Large Changes", "Unlisted PlaceId", "Never" }
local function Navbar(props)
return Theme.with(function(theme)

View File

@@ -516,6 +516,9 @@ function App:startSession()
return "Accept"
end
end
elseif confirmationBehavior == "Never" then
Log.trace("Accepting patch without confirmation because behavior is set to Never")
return "Accept"
end
-- The datamodel name gets overwritten by Studio, making confirmation of it intrusive