Skip to content

fix: strip trailing bracket from room-window title (no more "]]") - #43

Merged
MahtraDR merged 1 commit into
elanthia-online:mainfrom
MahtraDR:fix/room-window-double-bracket
Aug 6, 2026
Merged

fix: strip trailing bracket from room-window title (no more "]]")#43
MahtraDR merged 1 commit into
elanthia-online:mainfrom
MahtraDR:fix/room-window-double-bracket

Conversation

@MahtraDR

@MahtraDR MahtraDR commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Problem

RoomDataProcessor#process_room_data captured the room-window title with:

@room_pending_title = text.sub(/^\[/, '').sub(/\]\s*\(/, ' (').strip

That removes the leading [ unconditionally, but only removes the closing ] when it is immediately followed by a ( — i.e. the [Room] (230008) RealID form. A bracketed title without a trailing (number) keeps its ]:

  • [Bosque Deriel, Hermit's Shacks - 2071] — Lich's ;display lichid + ;display roomid title when the game RealID isn't appended → Bosque Deriel, Hermit's Shacks - 2071]
  • [Town Square] — any plain room → Town Square]

RoomWindow#render then re-brackets the title ("[#{@title}]"), doubling the stray bracket into [Bosque Deriel, Hermit's Shacks - 2071]].

(Surfaced while chasing a doubled ] alongside elanthia-online/lich-5#1500; that Lich PR fixes the DR side by preserving the game RealID, but this front-end regex is independently buggy for any bracketed title lacking a trailing (number).)

Fix

Also strip a trailing ], so the captured title is always bracket-free regardless of whether the game appended a RealID:

@room_pending_title = text.sub(/^\[/, '').sub(/\]\s*\(/, ' (').sub(/\]\s*\z/, '').strip

render then adds exactly one pair of brackets.

input (roomName text) captured title rendered
[Room] (230008) Room (230008) [Room] (230008)
[Room - 2071] Room - 2071 [Room - 2071] (was [Room - 2071]])
[Town Square] Town Square [Town Square] (was [Town Square]])
[Room - 2071] (230008) Room - 2071 (230008) [Room - 2071] (230008)

Tests

New spec/lib/room_data_processor_spec.rb drives #process_room_data in :title mode over the RealID, lich-id-only, plain, and combined title shapes, plus adversarial "leaves no stray ]" and no-RoomWindow cases.

Full suite green: 852 examples, 0 failures; rubocop clean on touched files.

🤖 Generated with Claude Code

Problem: RoomDataProcessor#process_room_data captured the room-window title with
"text.sub(/^\[/, '').sub(/\]\s*\(/, ' (').strip", which removes the leading "["
unconditionally but only removes the closing "]" when it is immediately followed
by a "(" (the "[Room] (230008)" RealID form). A bracketed title WITHOUT a trailing
"(number)" - e.g. "[Room - 2071]" (Lich's ";display lichid" + "roomid title" when
the game RealID is absent) or a plain "[Town Square]" - kept its trailing "]".
RoomWindow#render then re-brackets the title ("[#{@title}]"), doubling it into
"[Room - 2071]]".

Fix: Also strip a trailing "]" (".sub(/\]\s*\z/, '')") so the captured title is
always bracket-free regardless of whether the game appended a RealID. render then
adds exactly one pair of brackets.

Tests: New spec/lib/room_data_processor_spec.rb drives #process_room_data in
:title mode over the RealID, lich-id-only, plain, and combined title shapes, plus
adversarial "no stray ]" and no-RoomWindow cases. Full suite green: 852 examples,
0 failures; rubocop clean on touched files.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@MahtraDR
MahtraDR merged commit d7de327 into elanthia-online:main Aug 6, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant