From c71a5eba4fd62f421f30f3e76c9a4cc94189349f Mon Sep 17 00:00:00 2001 From: neotaso Date: Sat, 10 Jan 2026 16:16:40 +0900 Subject: [PATCH 1/3] =?UTF-8?q?StringScanner=E3=81=B8=E3=81=AE=E3=83=91?= =?UTF-8?q?=E3=83=83=E3=83=81=E3=81=AEpos=E4=BF=AE=E6=AD=A3=20fix:=20bcdic?= =?UTF-8?q?e/bcdice-js#72?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruby/patch.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ruby/patch.rb b/ruby/patch.rb index 11f2308..eaf0f14 100644 --- a/ruby/patch.rb +++ b/ruby/patch.rb @@ -41,8 +41,9 @@ def scan_until(pattern) continue; } - self.matched = self.string.substr(self.pos, pos - self.pos - 1 + result[0].length); - self.prev_pos = pos - 1; + pos = pos + result[0].length - 1; + self.matched = self.string.substr(self.pos, pos - self.pos); + self.prev_pos = self.pos; self.pos = pos; self.working = working.substr(result[0].length - 1); From 6b6e78d22735d406dc3c319075f7c1f43071f6b9 Mon Sep 17 00:00:00 2001 From: neotaso Date: Sun, 11 Jan 2026 20:01:01 +0900 Subject: [PATCH 2/3] =?UTF-8?q?lint=E5=AF=BE=E5=BF=9C=E3=81=AE=E3=81=9F?= =?UTF-8?q?=E3=82=81=E3=81=AEpatch=E5=AE=9F=E8=A3=85=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruby/patch.rb | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/ruby/patch.rb b/ruby/patch.rb index eaf0f14..8fb0c65 100644 --- a/ruby/patch.rb +++ b/ruby/patch.rb @@ -20,7 +20,6 @@ def scan_until(pattern) %x{ var self = this; - pattern = self.$anchor(pattern); var pos = self.pos, @@ -28,9 +27,9 @@ def scan_until(pattern) result; while (true) { - var isEmpty = working.length === 0; - result = pattern.exec(working); - pos += 1; + var isEmpty = working.length === 0; + result = pattern.exec(working); + pos += 1; working = working.substr(1); if (result == null) { @@ -41,13 +40,11 @@ def scan_until(pattern) continue; } - pos = pos + result[0].length - 1; - self.matched = self.string.substr(self.pos, pos - self.pos); self.prev_pos = self.pos; - self.pos = pos; + self.pos = pos + result[0].length - 1; self.working = working.substr(result[0].length - 1); - return self.matched; + return self.matched = self.string.substr(self.prev_pos, self.pos - self.prev_pos); } } end From 07c25ee6bcf3133e19a05d67ebca47867e08649c Mon Sep 17 00:00:00 2001 From: esnya <2088693+esnya@users.noreply.github.com> Date: Thu, 15 Jan 2026 21:03:21 +0900 Subject: [PATCH 3/3] =?UTF-8?q?test:=20=E2=9C=85=20add=20choice=20command?= =?UTF-8?q?=20regression=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ts/choice_command.test.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 ts/choice_command.test.ts diff --git a/ts/choice_command.test.ts b/ts/choice_command.test.ts new file mode 100644 index 0000000..8c773d9 --- /dev/null +++ b/ts/choice_command.test.ts @@ -0,0 +1,20 @@ +import { expect } from 'chai'; +import DynamicLoader from './loader/dynamic_loader'; +import { I18n } from './internal'; +import { mockRandomizer } from './test/randomizer'; + +describe('Choice command', () => { + it('keeps last item when multiple spaces between items', async () => { + I18n.$clear_translate_table(); + const loader = new DynamicLoader(); + const GameSystemClass = await loader.dynamicLoad('DiceBot'); + const gameSystem = new GameSystemClass('choice 123 456 789'); + + const $random = mockRandomizer(gameSystem); + $random.onCall(0).returns(3); + $random.onCall(1).throwsException(new Error('Unexpected call for $random')); + + const res = gameSystem.eval(); + expect(res?.text).to.equal('(choice 123 456 789) > 789'); + }); +});