You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Export: a path whose extension names the format is written as given - #4370
export in crates/engine/src/cmd/file.rs serves file.exportHtml and file.exportCsv. It kept the given path only when it ended with exactly .html or .csv, case-sensitively, and otherwise appended the extension. So page.htm, page.HTML and data.CSV were written as page.htm.html, page.HTML.html and data.CSV.csv. The commands reported success, and the requested files never appeared. file.saveAs with the same paths keeps them, as the issue shows.
What changed
A path keeps its name when its extension names the export's format. That uses io::FileKind::from_path, the same mapping that open and save use: it ignores letter case and knows .htm as HTML.
Any other path still gets the format's extension, as before: a bare name, or page.csv for an HTML export.
QA report
Main vs branch, end to end (gridcraft-cli run)
Each row is a fresh run that sets A1 and calls the command with the path in an empty folder. main is a gridcraft-cli built from origin/main (abcfc191); the branch is this PR (1d55e2c1).
Command
Path asked for
main writes
this PR writes
file.exportHtml
page.htm
page.htm.html
page.htm
file.exportHtml
page.HTML
page.HTML.html
page.HTML
file.exportCsv
data.CSV
data.CSV.csv
data.CSV
file.exportHtml
plain.html (control)
plain.html
plain.html
file.exportCsv
bare (control)
bare.csv
bare.csv
file.saveAs
book.HTM (the issue's comparison)
book.HTM
book.HTM
The folder held exactly those files afterwards, with nothing written under a doubled extension on the branch. The returned path names the file written in both builds.
for HTML: page.htm, page.HTML, page.Htm, page.html, a bare page (gets .html) and page.csv (gets .html);
for CSV: data.CSV, data.csv, a bare data (gets .csv), and data.htm and data.txt (both get .csv).
For each, it checks the returned path and that the file holds the cell, and that no doubled name exists.
Negative control
With the exact lower-case suffix check put back (on top of 1d55e2c1, then restored with git checkout), the test fails at file.exportHtml page.htm: left …/page.htm.html, right …/page.htm.
.txt for CSV:data.txt still gets .csv added. GridCraft reads .txt as tab-separated, so it isn't the CSV format's extension; that's unchanged from main.
Case-insensitive file systems: this Mac's APFS treats page.HTML and page.html as one file. The test's cases still hold there, and on Linux CI they're distinct files.
Windows: the issue was reproduced on Windows. I ran macOS only; the logic doesn't depend on the platform.
cargo xtask ci: I didn't run the full cargo xtask ci (wasm, layers, the other crates).
Summary by CodeRabbit
Bug Fixes
Export filenames now retain extensions that match the selected format, including case variations and supported alternatives. A format extension is added when the filename has no matching extension.
Tests
Added coverage for export filename handling and verifying that exported files are written to the returned path.
file.exportHtml and file.exportCsv compared the path with ".html" or ".csv" exactly, so page.htm, page.HTML and data.CSV were written as page.htm.html, page.HTML.html and data.CSV.csv, and the requested files never appeared. A path whose extension names the export's format, in any case or spelling, now keeps it, as file.saveAs does; any other path still gets the format's extension. Fixesstorytold#4355.
No actionable comments were generated in the recent review.
Walkthrough
Export recognizes extensions supported by the requested format, including case variants and alternate spellings. It appends the format extension when the path has no matching format. A native-only test checks returned paths and written files.
Export preserves paths whose extensions resolve to the requested FileKind and appends the requested extension otherwise. The native-only test covers HTML and CSV paths, returned paths, and written files.
Exports now keep a requested filename when its extension matches the format, including .htm, .HTML and .CSV. Other paths still get the format extension appended. No merge-blocking risk was identified.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title states the main behavior change: a path whose extension already names the export format is kept as given. The raw summary confirms the change in crates/engine/src/cmd/file.rs (FileKind-based…
Linked Issues check
Directly linked issue #4355 requires that file.exportHtml and file.exportCsv keep a requested path whose extension names the export format. Required cases: .htm and .HTML for HTML, and .CSV for CSV. L…
Out of Scope Changes check
The whole-PR diff against merge base abcfc19 changes two files. crates/engine/src/cmd/file.rs changes only the target-path decision in export, with a comment that cites #4355. crates/engine/src/tests…
Full details: Title check
Explanation
The title states the main behavior change: a path whose extension already names the export format is kept as given. The raw summary confirms the change in crates/engine/src/cmd/file.rs (FileKind-based extension detection for export) and the added test in crates/engine/src/tests.rs. The title is specific and matches the linked issue's request for preserved filenames. It does not mention the case-insensitive or .htm handling, which is a detail and not required.
Full details: Linked Issues check
Explanation
Directly linked issue #4355 requires that file.exportHtml and file.exportCsv keep a requested path whose extension names the export format. Required cases: .htm and .HTML for HTML, and .CSV for CSV. Lowercase canonical suffixes must stay, and suffixless paths must get the format extension.
Implementation at head (crates/engine/src/cmd/file.rs, export): the old check path.ends_with(".{ext}") is replaced. The path is kept when crate::io::FileKind::from_path(path) returns a kind equal to FileKind::from_path("export.{ext}"). Otherwise the extension is appended. Per the PR description and the added test, from_path ignores letter case and maps .htm to HTML. Therefore page.htm, page.HTML and data.CSV keep their names. page.html and data.csv are still kept. A bare name, or page.csv for an HTML export, still gets the extension.
Automated coverage: tests::exports_keep_a_path_whose_extension_names_the_format (crates/engine/src/tests.rs, +35 lines) checks returned paths, file contents and the absence of doubled names for these cases. The author reports a negative control: restoring the exact lowercase check fails the test.
Limits: the repository could not be read in this review, so from_path's case-insensitive and .htm behavior is taken from the PR description and the test, not re-read from source. Windows was not tested by the author, although the issue was reproduced on Windows.
Full details: Out of Scope Changes check
Explanation
The whole-PR diff against merge base abcfc19 changes two files. crates/engine/src/cmd/file.rs changes only the target-path decision in export, with a comment that cites #4355. crates/engine/src/tests.rs adds one native test for export filenames. Both changes serve the #4355 objective. No unrelated behavior change is shown. The PR description also states that .txt for CSV is unchanged, so no unrelated change is introduced there.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Reviewing files that changed from the base of the PR and between abcfc19 and 1d55e2c.
Files selected for processing: 2
crates/engine/src/cmd/file.rs
crates/engine/src/tests.rs
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 2 remain after this review.
emrahoksak
pushed a commit
to emrahoksak/girdcraft-
that referenced
this pull request
Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4355
What was wrong
exportincrates/engine/src/cmd/file.rsservesfile.exportHtmlandfile.exportCsv. It kept the given path only when it ended with exactly.htmlor.csv, case-sensitively, and otherwise appended the extension. Sopage.htm,page.HTMLanddata.CSVwere written aspage.htm.html,page.HTML.htmlanddata.CSV.csv. The commands reported success, and the requested files never appeared.file.saveAswith the same paths keeps them, as the issue shows.What changed
io::FileKind::from_path, the same mapping that open and save use: it ignores letter case and knows.htmas HTML.page.csvfor an HTML export.QA report
Main vs branch, end to end (
gridcraft-cli run)Each row is a fresh run that sets A1 and calls the command with the path in an empty folder.
mainis agridcraft-clibuilt fromorigin/main(abcfc191); the branch is this PR (1d55e2c1).file.exportHtmlpage.htmpage.htm.htmlpage.htmfile.exportHtmlpage.HTMLpage.HTML.htmlpage.HTMLfile.exportCsvdata.CSVdata.CSV.csvdata.CSVfile.exportHtmlplain.html(control)plain.htmlplain.htmlfile.exportCsvbare(control)bare.csvbare.csvfile.saveAsbook.HTM(the issue's comparison)book.HTMbook.HTMThe folder held exactly those files afterwards, with nothing written under a doubled extension on the branch. The returned
pathnames the file written in both builds.Test
tests::exports_keep_a_path_whose_extension_names_the_formatwrites:page.htm,page.HTML,page.Htm,page.html, a barepage(gets.html) andpage.csv(gets.html);data.CSV,data.csv, a baredata(gets.csv), anddata.htmanddata.txt(both get.csv).For each, it checks the returned path and that the file holds the cell, and that no doubled name exists.
Negative control
With the exact lower-case suffix check put back (on top of
1d55e2c1, then restored withgit checkout), the test fails atfile.exportHtml page.htm: left…/page.htm.html, right…/page.htm.Gate (macOS arm64)
cargo fmt --all -- --checkcargo clippy -p gridcraft-engine --all-targets -- -D warningscargo test -p gridcraft-engine -p gridcraft-xlsxNot covered
.txtfor CSV:data.txtstill gets.csvadded. GridCraft reads.txtas tab-separated, so it isn't the CSV format's extension; that's unchanged frommain.page.HTMLandpage.htmlas one file. The test's cases still hold there, and on Linux CI they're distinct files.cargo xtask ci: I didn't run the fullcargo xtask ci(wasm, layers, the other crates).Summary by CodeRabbit