fix: 终端 PTY 尺寸同步
前端在 xterm fit/resize 后通过 WebSocket 发送 resize 控制消息,后端收到后调用 ChannelShell.setPtySize 触发远端重绘,修复 less/vim/top 等全屏程序只显示部分区域的问题。 同时补齐控制消息解析与 PTY resize 的单测,并修正失配的 SftpControllerTest 断言。
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package com.sshmanager.service;
|
||||
|
||||
import com.jcraft.jsch.ChannelShell;
|
||||
import com.jcraft.jsch.Session;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
class SshSessionResizeTest {
|
||||
|
||||
@Test
|
||||
void resizeSetsPtySizeOnChannel() {
|
||||
Session session = mock(Session.class);
|
||||
ChannelShell channel = mock(ChannelShell.class);
|
||||
InputStream out = mock(InputStream.class);
|
||||
OutputStream in = mock(OutputStream.class);
|
||||
|
||||
SshService.SshSession sshSession = new SshService.SshSession(session, channel, out, in);
|
||||
sshSession.resize(120, 40);
|
||||
|
||||
verify(channel).setPtySize(120, 40, 0, 0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user