Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] EvEditor - Do not add string-casted None literals to buffer #2222

Closed
strikaco opened this issue Oct 11, 2020 · 2 comments
Closed
Labels
devel-implemented Already finished, usually in a branch not yet merged. feature-request A suggestion for new functionality. good first issue Low hanging fruit for those wanting to help out.

Comments

@strikaco
Copy link
Contributor

Is your feature request related to a problem? Please describe.

When editing an attribute using set/edit, if the attribute in question is unset or otherwise None, the string "None" is prepended to the buffer.

----------Line Editor [object/name]-----------------------------------------
01| None
----------[l:01 w:001 c:0004]------------(:h for help)------------------------

Using the editor to set an initial value requires the first step to be :x 1 in order to actually start with a clean slate.

Describe the solution you'd like

I'd suggest that if the existing attribute value is anything other than a string, the editor should at least warn the user about the type mismatch.

In cases where the value is the literal None or otherwise evaluates to False, these should simply not be appended to the buffer.

@strikaco strikaco added the feature-request A suggestion for new functionality. label Oct 11, 2020
@strikaco
Copy link
Contributor Author

I do see some existing commands that implement the editor perform typechecking, but this could be better enforced by the editor itself.

if old_value is not None and not isinstance(old_value, str):
            typ = type(old_value).__name__
            self.caller.msg(
                "|RWARNING! Saving this buffer will overwrite the "
                "current attribute (of type %s) with a string!|n" % typ
            )
            return str(old_value)

@Griatch Griatch added good first issue Low hanging fruit for those wanting to help out. Hacktoberfest Help out in October and win prizes! https://hacktoberfest.digitalocean.com/ labels Oct 11, 2020
@Griatch Griatch removed the Hacktoberfest Help out in October and win prizes! https://hacktoberfest.digitalocean.com/ label Nov 1, 2020
@Griatch
Copy link
Member

Griatch commented Oct 8, 2021

The editor already defaults to warning in red if trying to edit a non-string. I made a previously undefined Attribute come out as an empty string in set/edit command also added a confirmation question to confirm, since that use of the editor is so likely to encounter non-strings. Closing.

@Griatch Griatch closed this as completed Oct 8, 2021
@Griatch Griatch added branch-develop devel-implemented Already finished, usually in a branch not yet merged. labels Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devel-implemented Already finished, usually in a branch not yet merged. feature-request A suggestion for new functionality. good first issue Low hanging fruit for those wanting to help out.
Projects
None yet
Development

No branches or pull requests

2 participants