new line is lost when sending multiple lines on visual mode
pinggit opened this issue · comments
pinggit commented
when visually mark and press \w
to send multiple lines to repl, the new lines got lost.
see this example:
output1 = """
R1#show ip interface brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 15.0.15.1 YES manual up up
FastEthernet0/1 10.0.12.1 YES manual up up
FastEthernet0/2 10.0.13.1 YES manual up up
FastEthernet0/3 unassigned YES unset up up
Loopback0 10.1.1.1 YES manual up up
Loopback100 100.0.0.1 YES manual up up
"""
after visually marked and pressed \w
:
In [128]: output1 = """R1#show ip interface briefInterface IP-Ad
...: dress OK? Method Status ProtocolFastEthernet0/0
...: 15.0.15.1 YES manual up upFastEthernet
...: 0/1 10.0.12.1 YES manual up upFastE
...: thernet0/2 10.0.13.1 YES manual up
...: upFastEthernet0/3 unassigned YES unset up
...: upLoopback0 10.1.1.1 YES manual up
...: upLoopback100 100.0.0.1 YES manual u
...: p up"""
In [129]: output1
Out[129]: 'R1#show ip interface briefInterface IP-Address O
K? Method Status ProtocolFastEthernet0/0 15.0.15.1
YES manual up upFastEthernet0/1 10.0.12.1 Y
ES manual up upFastEthernet0/2 10.0.13.1 YES
manual up upFastEthernet0/3 unassigned YES uns
et up upLoopback0 10.1.1.1 YES manual
up upLoopback100 100.0.0.1 YES manual up
up'
comparing with manually copy and paste:
In [126]: output1 = """R1#show ip interface brief
...: Interface IP-Address OK? Method Status
...: Protocol
...: FastEthernet0/0 15.0.15.1 YES manual up
...: up
...: FastEthernet0/1 10.0.12.1 YES manual up
...: up
...: FastEthernet0/2 10.0.13.1 YES manual up
...: up
...: FastEthernet0/3 unassigned YES unset up
...: up
...: Loopback0 10.1.1.1 YES manual up
...: up
...: Loopback100 100.0.0.1 YES manual up
...: up
...: """
In [127]: output1
Out[127]: 'R1#show ip interface brief\nInterface IP-Address
OK? Method Status Protocol\nFastEthernet0/0 15.0.15.1
YES manual up up\nFastEthernet0/1 10.0.12.1
YES manual up up\nFastEthernet0/2 10.0.13.1
YES manual up up\nFastEthernet0/3 unassigned
YES unset up up\nLoopback0 10.1.1.1
YES manual up up\nLoopback100 100.0.0.1
YES manual up up\n'
Notice the \n
is here.
is there an option to workaround this?
Yiteng Zhang. commented
I can repo this bug. I will fix it.
Yiteng Zhang. commented
This bug has been fixed. Please update the plugin.
pinggit commented
this does not work for raw string...
for raw string with current behavior \n is added for each line, which is wrong.
Yiteng Zhang. commented
Yiteng Zhang. commented
I see what's happened, and will fix it out.
pinggit commented
[ins] In [31]: ##send with \w:
[ins] In [24]: s = r"""abc\ndef\n"""
[ins] In [25]: sr = r"""abc\ndef\n"""
[ins] In [26]: sr = """abc\ndef\n"""
[ins] In [27]: s
Out[27]: 'abc\\ndef\\n'
[ins] In [28]: sr
Out[28]: 'abc\ndef\n'
[ins] In [29]:
[ins] In [29]:
[ins] In [29]: print(s)
abc\ndef\n
[ins] In [30]: print(sr)
abc
def
comparing with manually copy and paste behavior:
[ins] In [31]: ##now copy paste
[ins] In [32]: s = r"""abc
...: def
...: """
...:
[ins] In [33]: sr = """abc
...: def
...: """
...:
[ins] In [34]: s
Out[34]: 'abc\ndef\n'
[ins] In [35]: sr
Out[35]: 'abc\ndef\n'
[ins] In [36]: print(s)
abc
def
[ins] In [37]
Yiteng Zhang. commented
@pinggit This bug has been fixed. Please update the plugin to check it.