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

Fix editor's range specification #3464

Merged
merged 1 commit into from Apr 1, 2024
Merged

Conversation

chiizujin
Copy link
Contributor

Brief overview of PR changes/additions

The editor's range specification (n:n) returns at most two lines. This has been fixed.

Also, as part of this:

  • An existing unit test has been corrected
  • New unit tests have been added to test various ranges
  • utils.value_is_integer(value) has been added which returns True if value can be type-cast to an integer and False otherwise. This is to allow checking for negative integers, which str.isdigit() can't do.

Motivation for adding to Evennia

Fix editor range specification.

Other info

Test buffer

>:
----------Line Editor [desc]--------------------------------------------------
01| line 1
02| line 2
03| line 3
04| line 4
05| line 5
----------[l:05 w:010 c:0034]------------(:h for help)------------------------

Before

>: 1:5
----------Line Editor [desc]--------------------------------------------------
01| line 1
02| line 2
----------[l:02 w:004 c:0013]------------(:h for help)------------------------

After

>: 1:5
----------Line Editor [desc]--------------------------------------------------
01| line 1
02| line 2
03| line 3
04| line 4
05| line 5
----------[l:05 w:010 c:0034]------------(:h for help)------------------------

Changed unit test

def test_eveditor_COLON_F(self):
    eveditor.EvEditor(self.char1)
    self.call(
        eveditor.CmdEditorGroup(),
        "",
        cmdstring=":",
        msg="Line Editor []\n01\n[l:01 w:000 c:0000](:h for help)",
    )
    self.call(eveditor.CmdLineInput(), "line 1", raw_string="line 1", msg="01line 1")
    self.call(eveditor.CmdEditorGroup(), "1:2", cmdstring=":f", msg="Flood filled lines 1-2.

This test expects the output "Flood filled lines 1-2." for a buffer containing only one line. After the fix the above command will return "Flood filled line 1.", which is correct. The test has been updated to look for the new output.

Comment on lines +3092 to +3097
try:
int(value)
except ValueError:
return False

return True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine, but in case you were not aware, you can also do try: ... except: ... else: ... in Python :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I always forget about else in try blocks.

Copy link
Member

@Griatch Griatch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good attention to detail. And looks like a clean fix supported by unit tests. Nice!

@Griatch Griatch merged commit 371fd15 into evennia:main Apr 1, 2024
7 of 10 checks passed
@chiizujin chiizujin deleted the editor_range branch April 1, 2024 09:20
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.

None yet

2 participants