[BUG] EvTable dropping whitespaces after first line
elee-p3 opened this issue · comments
Describe the bug
Effectively identical behavior as #3193, but these aren't nested tables - these are straightforward EvTables. We're outputting the tables as strings via myEvTable.__str__()
, which could be part of the issue if this isn't standard practice.
On upgrade from 0.9.5 to 2.3.0, the functionality was still working as expected, but on the move from 2.3.0 to 3.1.0, this issue appeared.
Note: the below screenshots contain two EvTables that have been
EvTable behavior on 2.3.0:
To Reproduce
Steps to reproduce the behavior:
- Create a multi-row EvTable on any evennia version between 0.9.5 and 2.3.0
- Migrate to version 3.1.0
- View the same EvTable
- See error
Expected behavior
EvTable maintains proper spacing throughout table.
Environment, Evennia version, OS etc
Python 3.11, Evennia 3.1.0, Windows 10 Build 19045.3803
Additional context
N/A
Does this happen in both the webclient and in telnet?
(Also, the __str__
method is what's called by str()
; the more usual syntax is to do str(table)
than table.__str__()
, but they should function identically.)
@elee-p3 Could you provide the code for creating this table (or a smaller table showcasing the effect)? I don't see no issues with a simple left-aligned table with spaces, so it would be useful to know exactly how you create the table to understand what could be the issue.
Absolutely. Also, I think I've got a better handle of the issue now - it seems to stem from EvTable no longer respecting the width=
argument for non-header rows. Here's a simpler repro, and the code snippet for generating the table.
Code:
class CmdSheet(default_cmds.MuxCommand):
def func(self):
caller = self.caller
client_width = self.client_width()
sheetMsg = ""
charInfoTable = evtable.EvTable(border_left_char="|", border_right_char="|", border_top_char="-",
border_bottom_char=" ", width=client_width, border="table")
charInfoTable.add_column()
charInfoTable.add_column()
charInfoTable.add_column()
charInfoTable.add_column()
charInfoTable.reformat_column(0, align='l') # resource label
charInfoTable.reformat_column(1, align='r') # resource value
charInfoTable.reformat_column(2, align='l') # stat label
charInfoTable.reformat_column(3, align='l') # stat value
charInfoTable.add_row("col1", "col2", "col3", "col4")
charInfoString = charInfoTable.__str__()
sheetMsg += charInfoString[:charInfoString.rfind('\n')] + "\n" # delete last newline (i.e. bottom border)
self.caller.msg(sheetMsg)
Let me know if you need any more information.
Huh - I guess the only significant difference is the OS? And I actually just stumbled on the what the actual issue seems to be: somehow on my machine, self.caller.msg
is turning all whitespace with a length > 1 to a single whitespace. e.g.
caller.msg(" testing this out")
is being printed out as
testing this out
Huh - I guess the only significant difference is the OS? And I actually just stumbled on the what the actual issue seems to be: somehow on my machine,
self.caller.msg
is turning all whitespace with a length > 1 to a single whitespace. e.g.caller.msg(" testing this out")
is being printed out as
testing this out
Is this on the webclient? If so, you may want to try clearing your cache.
that did it! Out of curiosity, do you have any idea what that was all about?
Either way, you can close this out - thank you!
I do! That's why my very first question was if it was happening on both the webclient and telnet. xD
In the 1.0 release, there was a change made to the CSS file for the webclient so that it would render whitespace characters instead of the server having to replace them all with
. The default behavior for browsers is to compress all the whitespace to a single displayed space, so if your browser still has the old pre-1.0 webclient files cached, it wouldn't render the spaces properly.
Looks like this can be closed then 👍 Good to know that this particular issue can be handled with a cache clean.