Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.0
hooks:
- id: clang-format
types_or: [c++, c, cuda]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: check-case-conflict
- id: check-illegal-windows-names
- id: check-json
- id: check-toml
- id: check-xml
- id: check-yaml
- id: detect-private-key
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: trailing-whitespace
exclude: .ink$
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0 # Use the ref you want to point at
hooks:
- id: text-unicode-replacement-char
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.10
hooks:
- id: cmake-format
- id: cmake-lint
7 changes: 1 addition & 6 deletions inkcpp/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,15 +392,10 @@ char* basic_stream::get_alloc(string_table& strings, list_table& lists)
_size = start;

// Return processed string
end = clean_string<true, false>(buffer, buffer + c_str_len(buffer));
end = clean_string<RemoveTail, RemoveTail>(buffer, buffer + c_str_len(buffer));
*end = 0;
if (end != buffer) {
_last_char = end[-1];
if constexpr (RemoveTail) {
if (_last_char == ' ') {
end[-1] = 0;
}
}
} else {
_last_char = 'e';
}
Expand Down
25 changes: 25 additions & 0 deletions inkcpp_test/Fixes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,28 @@ SCENARIO("snapshot failed inside execution _ #111", "[fixes]")
}
}
}

SCENARIO("missing leading whitespace inside choice-only text and glued text _ #130 #131", "[fixes]")
{
GIVEN("story with problematic text")
{
auto ink = story::from_file(INK_TEST_RESOURCE_DIR "130_131_missing_whitespace.bin");
runner thread = ink->new_runner();
WHEN("run story")
{
auto line = thread->getline();
THEN("expect spaces in glued text") { REQUIRE(line == "Glue with no gaps.\n"); }
THEN("choice contains space")
{
REQUIRE(thread->num_choices() == 1);
REQUIRE(std::string(thread->get_choice(0)->text()) == "Look around");
}
thread->choose(0);
line = thread->getall();
THEN("no space in post choice text")
{
REQUIRE(line == "Looking around the saloon, you don't find much.");
}
}
}
}
8 changes: 8 additions & 0 deletions inkcpp_test/ink/130_131_missing_whitespace.ink
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
~temp test = true
Glue <>
{
- test: with
} <> {
- test: no
} <> gaps.
+ Look[ around]ing around the saloon, you don't find much.->DONE
Loading