File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,6 +26,14 @@ class Buffer(Remote):
2626
2727 _api_prefix = "nvim_buf_"
2828
29+ def __repr__ (self ):
30+ """Get text representation of the buffer."""
31+ return 'Buffer(number=%r, name=%r, filetype=%r)' % (
32+ self .number ,
33+ self .name ,
34+ self .options .get ('filetype' ),
35+ )
36+
2937 def __len__ (self ):
3038 """Return the number of lines contained in a Buffer."""
3139 return self .request ('nvim_buf_line_count' )
Original file line number Diff line number Diff line change @@ -19,6 +19,13 @@ def __init__(self, *args):
1919 super (Tabpage , self ).__init__ (* args )
2020 self .windows = RemoteSequence (self , 'nvim_tabpage_list_wins' )
2121
22+ def __repr__ (self ):
23+ """Get text representation of the tabpage."""
24+ return 'Tabpage(number=%r, window=%r)' % (
25+ self .number ,
26+ self .window ,
27+ )
28+
2229 @property
2330 def window (self ):
2431 """Get the `Window` currently focused on the tabpage."""
Original file line number Diff line number Diff line change @@ -11,6 +11,13 @@ class Window(Remote):
1111
1212 _api_prefix = "nvim_win_"
1313
14+ def __repr__ (self ):
15+ """Get text representation of the window."""
16+ return 'Window(number=%r, buffer=%r)' % (
17+ self .number ,
18+ self .buffer ,
19+ )
20+
1421 @property
1522 def buffer (self ):
1623 """Get the `Buffer` currently being displayed by the window."""
Original file line number Diff line number Diff line change 33from neovim .compat import IS_PYTHON3
44
55
6+ def test_repr (vim ):
7+ assert repr (vim .current .buffer ) == "Buffer(number=2, name='')"
8+ vim .command ('file name with spaces' )
9+ fname = os .path .join (os .getcwd (), 'name with spaces' )
10+ assert repr (vim .current .buffer ) == "Buffer(number=2, name='%s')" % fname
11+
12+
613def test_get_length (vim ):
714 assert len (vim .current .buffer ) == 1
815 vim .current .buffer .append ('line' )
You can’t perform that action at this time.
0 commit comments