aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nimterop/toast.nim8
1 files changed, 5 insertions, 3 deletions
diff --git a/nimterop/toast.nim b/nimterop/toast.nim
index 871230d..5923e56 100644
--- a/nimterop/toast.nim
+++ b/nimterop/toast.nim
@@ -222,9 +222,11 @@ proc main(
# Include in wrapper file
data = outputFile.readFile()
- if "type\n" in data:
- # In existing type block
- data = data.replace("type\n", "type\n" & stubData)
+ let
+ idx = data.find("\ntype\n")
+ if idx != -1:
+ # In first existing type block
+ data = data[0 ..< idx+6] & stubData & data[idx+6 .. ^1]
else:
# At the top if none already
data = "type\n" & stubData & data