Skip to content

Commit 08f37f9

Browse files
committed
[ new ] Loggings for exposing issue #250 on Windows
1 parent d9905a2 commit 08f37f9

File tree

6 files changed

+317
-38
lines changed

6 files changed

+317
-38
lines changed

lib/js/src/Agda.bs.js

Lines changed: 34 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/js/src/Goals.bs.js

Lines changed: 36 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/js/test/tests/Test__Goals.bs.js

Lines changed: 91 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Agda.res

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@ module OffsetConverter: OffsetConverter = {
269269
// length in code units (16 bits), not the actual code point length
270270
let lengthInCodeUnits = String.length(text)
271271

272+
Js.log("=== computeUTF16SurrogatePairIndices DEBUG START ===")
273+
Js.log("Text to process:")
274+
Js.log(text)
275+
Js.log("Text length in code units: " ++ Int.toString(lengthInCodeUnits))
276+
272277
// iterate through the text to find surrogate pairs
273278
let i = ref(0)
274279
while i.contents < lengthInCodeUnits {
@@ -279,9 +284,13 @@ module OffsetConverter: OffsetConverter = {
279284
if charCode >= 0xD800 && (charCode <= 0xDBFF && notFinal) {
280285
// found the high surrogate, proceed to check the low surrogate
281286
let nextCharCode = text->String.charCodeAt(i.contents + 1)->int_of_float
287+
Js.log(`High surrogate found at index ${Int.toString(i.contents)}: charCode=${Int.toString(charCode)}, nextCharCode=${Int.toString(nextCharCode)}`)
282288
if nextCharCode >= 0xDC00 && nextCharCode <= 0xDFFF {
283289
// store the index of this surrogate pair
284290
surrogatePairs->Array.push(i.contents)
291+
Js.log(`Valid surrogate pair found at index ${Int.toString(i.contents)}`)
292+
} else {
293+
Js.log(`Invalid low surrogate: nextCharCode=${Int.toString(nextCharCode)} (expected 0xDC00-0xDFFF)`)
285294
}
286295
// increment by 2 because we have checked the presumably low surrogate char
287296
i := i.contents + 2
@@ -290,6 +299,9 @@ module OffsetConverter: OffsetConverter = {
290299
}
291300
}
292301

302+
Js.log("Final surrogate pairs array:")
303+
Js.log(surrogatePairs)
304+
Js.log("=== computeUTF16SurrogatePairIndices DEBUG END ===")
293305
surrogatePairs
294306
}
295307

@@ -319,14 +331,38 @@ module OffsetConverter: OffsetConverter = {
319331
}
320332

321333
let make = text => {
322-
utf16indices: Indices.make(computeUTF16SurrogatePairIndices(text)),
323-
eolIndices: Indices.make(computeCRLFIndices(text)),
334+
let surrogatePairIndices = computeUTF16SurrogatePairIndices(text)
335+
let crlfIndices = computeCRLFIndices(text)
336+
337+
Js.log("=== OffsetConverter.make DEBUG ===")
338+
Js.log("Creating OffsetConverter for text:")
339+
Js.log(text)
340+
Js.log("Surrogate pair indices:")
341+
Js.log(surrogatePairIndices)
342+
Js.log("CRLF indices:")
343+
Js.log(crlfIndices)
344+
345+
let result = {
346+
utf16indices: Indices.make(surrogatePairIndices),
347+
eolIndices: Indices.make(crlfIndices),
348+
}
349+
350+
Js.log("Created OffsetConverter")
351+
result
324352
}
325353

326354
let convert = (self, offset) => {
355+
Js.log(`=== OffsetConverter.convert DEBUG ===`)
356+
Js.log(`Input offset: ${Int.toString(offset)}`)
357+
327358
// code point -> code unit
328359
let offset = Indices.convert(self.utf16indices, offset)
360+
Js.log(`After UTF-16 conversion: ${Int.toString(offset)}`)
361+
329362
// LF -> CRLF
330-
Indices.convert(self.eolIndices, offset)
363+
let finalOffset = Indices.convert(self.eolIndices, offset)
364+
Js.log(`After CRLF conversion: ${Int.toString(finalOffset)}`)
365+
366+
finalOffset
331367
}
332368
}

0 commit comments

Comments
 (0)