Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
76ddb455
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
76ddb455
编写于
4月 10, 2020
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adopt xterm buffer API changes
上级
613261ce
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
25 addition
and
25 deletion
+25
-25
src/vs/workbench/contrib/terminal/browser/addons/commandTrackerAddon.ts
...ch/contrib/terminal/browser/addons/commandTrackerAddon.ts
+8
-8
src/vs/workbench/contrib/terminal/browser/addons/navigationModeAddon.ts
...ch/contrib/terminal/browser/addons/navigationModeAddon.ts
+2
-2
src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
...vs/workbench/contrib/terminal/browser/terminalInstance.ts
+5
-5
src/vs/workbench/contrib/terminal/test/browser/terminalCommandTracker.test.ts
...trib/terminal/test/browser/terminalCommandTracker.test.ts
+10
-10
未找到文件。
src/vs/workbench/contrib/terminal/browser/addons/commandTrackerAddon.ts
浏览文件 @
76ddb455
...
...
@@ -50,7 +50,7 @@ export class CommandTrackerAddon implements ICommandTracker, ITerminalAddon {
if
(
!
this
.
_terminal
)
{
return
;
}
if
(
this
.
_terminal
.
buffer
.
cursorX
>=
MINIMUM_PROMPT_LENGTH
)
{
if
(
this
.
_terminal
.
buffer
.
active
.
cursorX
>=
MINIMUM_PROMPT_LENGTH
)
{
this
.
_terminal
.
registerMarker
(
0
);
}
}
...
...
@@ -64,8 +64,8 @@ export class CommandTrackerAddon implements ICommandTracker, ITerminalAddon {
}
let
markerIndex
;
const
currentLineY
=
Math
.
min
(
this
.
_getLine
(
this
.
_terminal
,
this
.
_currentMarker
),
this
.
_terminal
.
buffer
.
baseY
);
const
viewportY
=
this
.
_terminal
.
buffer
.
viewportY
;
const
currentLineY
=
Math
.
min
(
this
.
_getLine
(
this
.
_terminal
,
this
.
_currentMarker
),
this
.
_terminal
.
buffer
.
active
.
baseY
);
const
viewportY
=
this
.
_terminal
.
buffer
.
active
.
viewportY
;
if
(
!
retainSelection
&&
currentLineY
!==
viewportY
)
{
// The user has scrolled, find the line based on the current scroll position. This only
// works when not retaining selection
...
...
@@ -103,8 +103,8 @@ export class CommandTrackerAddon implements ICommandTracker, ITerminalAddon {
}
let
markerIndex
;
const
currentLineY
=
Math
.
min
(
this
.
_getLine
(
this
.
_terminal
,
this
.
_currentMarker
),
this
.
_terminal
.
buffer
.
baseY
);
const
viewportY
=
this
.
_terminal
.
buffer
.
viewportY
;
const
currentLineY
=
Math
.
min
(
this
.
_getLine
(
this
.
_terminal
,
this
.
_currentMarker
),
this
.
_terminal
.
buffer
.
active
.
baseY
);
const
viewportY
=
this
.
_terminal
.
buffer
.
active
.
viewportY
;
if
(
!
retainSelection
&&
currentLineY
!==
viewportY
)
{
// The user has scrolled, find the line based on the current scroll position. This only
// works when not retaining selection
...
...
@@ -212,7 +212,7 @@ export class CommandTrackerAddon implements ICommandTracker, ITerminalAddon {
private
_getLine
(
xterm
:
Terminal
,
marker
:
IMarker
|
Boundary
):
number
{
// Use the _second last_ row as the last row is likely the prompt
if
(
marker
===
Boundary
.
Bottom
)
{
return
xterm
.
buffer
.
baseY
+
xterm
.
rows
-
1
;
return
xterm
.
buffer
.
active
.
baseY
+
xterm
.
rows
-
1
;
}
if
(
marker
===
Boundary
.
Top
)
{
...
...
@@ -272,10 +272,10 @@ export class CommandTrackerAddon implements ICommandTracker, ITerminalAddon {
if
(
this
.
_currentMarker
===
Boundary
.
Bottom
)
{
return
0
;
}
else
if
(
this
.
_currentMarker
===
Boundary
.
Top
)
{
return
0
-
(
xterm
.
buffer
.
baseY
+
xterm
.
buffer
.
cursorY
);
return
0
-
(
xterm
.
buffer
.
active
.
baseY
+
xterm
.
buffer
.
active
.
cursorY
);
}
else
{
let
offset
=
this
.
_getLine
(
xterm
,
this
.
_currentMarker
);
offset
-=
xterm
.
buffer
.
baseY
+
xterm
.
buffer
.
cursorY
;
offset
-=
xterm
.
buffer
.
active
.
baseY
+
xterm
.
buffer
.
active
.
cursorY
;
return
offset
;
}
}
...
...
src/vs/workbench/contrib/terminal/browser/addons/navigationModeAddon.ts
浏览文件 @
76ddb455
...
...
@@ -55,7 +55,7 @@ export class NavigationModeAddon implements INavigationMode, ITerminalAddon {
}
// Target is row before the cursor
const
targetRow
=
Math
.
max
(
this
.
_terminal
.
buffer
.
cursorY
-
1
,
0
);
const
targetRow
=
Math
.
max
(
this
.
_terminal
.
buffer
.
active
.
cursorY
-
1
,
0
);
// Check bounds
if
(
treeContainer
.
childElementCount
<
targetRow
)
{
...
...
@@ -98,7 +98,7 @@ export class NavigationModeAddon implements INavigationMode, ITerminalAddon {
}
// Target is cursor row
const
targetRow
=
this
.
_terminal
.
buffer
.
cursorY
;
const
targetRow
=
this
.
_terminal
.
buffer
.
active
.
cursorY
;
// Check bounds
if
(
treeContainer
.
childElementCount
<
targetRow
)
{
...
...
src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
浏览文件 @
76ddb455
...
...
@@ -735,7 +735,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
}
if
(
this
.
_xterm
)
{
const
buffer
=
this
.
_xterm
.
buffer
;
this
.
_sendLineData
(
buffer
,
buffer
.
baseY
+
buffer
.
cursorY
);
this
.
_sendLineData
(
buffer
.
active
,
buffer
.
active
.
baseY
+
buffer
.
active
.
cursorY
);
this
.
_xterm
.
dispose
();
}
...
...
@@ -813,7 +813,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
// change since the number of visible rows decreases.
// This can likely be removed after https://github.com/xtermjs/xterm.js/issues/291 is
// fixed upstream.
this
.
_xtermCore
.
_onScroll
.
fire
(
this
.
_xterm
.
buffer
.
viewportY
);
this
.
_xtermCore
.
_onScroll
.
fire
(
this
.
_xterm
.
buffer
.
active
.
viewportY
);
if
(
this
.
_container
&&
this
.
_container
.
parentElement
)
{
// Force a layout when the instance becomes invisible. This is particularly important
// for ensuring that terminals that are created in the background by an extension will
...
...
@@ -1065,15 +1065,15 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
private
_onLineFeed
():
void
{
const
buffer
=
this
.
_xterm
!
.
buffer
;
const
newLine
=
buffer
.
getLine
(
buffer
.
baseY
+
buffer
.
cursorY
);
const
newLine
=
buffer
.
active
.
getLine
(
buffer
.
active
.
baseY
+
buffer
.
active
.
cursorY
);
if
(
newLine
&&
!
newLine
.
isWrapped
)
{
this
.
_sendLineData
(
buffer
,
buffer
.
baseY
+
buffer
.
cursorY
-
1
);
this
.
_sendLineData
(
buffer
.
active
,
buffer
.
active
.
baseY
+
buffer
.
active
.
cursorY
-
1
);
}
}
private
_onCursorMove
():
void
{
const
buffer
=
this
.
_xterm
!
.
buffer
;
this
.
_sendLineData
(
buffer
,
buffer
.
baseY
+
buffer
.
cursorY
);
this
.
_sendLineData
(
buffer
.
active
,
buffer
.
active
.
baseY
+
buffer
.
active
.
cursorY
);
}
private
_onTitleChange
(
title
:
string
):
void
{
...
...
src/vs/workbench/contrib/terminal/test/browser/terminalCommandTracker.test.ts
浏览文件 @
76ddb455
...
...
@@ -61,24 +61,24 @@ suite('Workbench - TerminalCommandTracker', () => {
for
(
let
i
=
0
;
i
<
20
;
i
++
)
{
await
writePromise
(
xterm
,
`\r\n`
);
}
assert
.
equal
(
xterm
.
buffer
.
baseY
,
20
);
assert
.
equal
(
xterm
.
buffer
.
viewportY
,
20
);
assert
.
equal
(
xterm
.
buffer
.
active
.
baseY
,
20
);
assert
.
equal
(
xterm
.
buffer
.
active
.
viewportY
,
20
);
// Scroll to marker
commandTracker
.
scrollToPreviousCommand
();
assert
.
equal
(
xterm
.
buffer
.
viewportY
,
9
);
assert
.
equal
(
xterm
.
buffer
.
active
.
viewportY
,
9
);
// Scroll to top boundary
commandTracker
.
scrollToPreviousCommand
();
assert
.
equal
(
xterm
.
buffer
.
viewportY
,
0
);
assert
.
equal
(
xterm
.
buffer
.
active
.
viewportY
,
0
);
// Scroll to marker
commandTracker
.
scrollToNextCommand
();
assert
.
equal
(
xterm
.
buffer
.
viewportY
,
9
);
assert
.
equal
(
xterm
.
buffer
.
active
.
viewportY
,
9
);
// Scroll to bottom boundary
commandTracker
.
scrollToNextCommand
();
assert
.
equal
(
xterm
.
buffer
.
viewportY
,
20
);
assert
.
equal
(
xterm
.
buffer
.
active
.
viewportY
,
20
);
});
test
(
'
should select to the next and previous commands
'
,
async
()
=>
{
(
<
any
>
window
).
matchMedia
=
()
=>
{
...
...
@@ -99,8 +99,8 @@ suite('Workbench - TerminalCommandTracker', () => {
assert
.
equal
(
xterm
.
markers
[
1
].
line
,
11
);
await
writePromise
(
xterm
,
'
\n\r
3
'
);
assert
.
equal
(
xterm
.
buffer
.
baseY
,
3
);
assert
.
equal
(
xterm
.
buffer
.
viewportY
,
3
);
assert
.
equal
(
xterm
.
buffer
.
active
.
baseY
,
3
);
assert
.
equal
(
xterm
.
buffer
.
active
.
viewportY
,
3
);
assert
.
equal
(
xterm
.
getSelection
(),
''
);
commandTracker
.
selectToPreviousCommand
();
...
...
@@ -133,8 +133,8 @@ suite('Workbench - TerminalCommandTracker', () => {
assert
.
equal
(
xterm
.
markers
[
1
].
line
,
11
);
await
writePromise
(
xterm
,
'
\n\r
3
'
);
assert
.
equal
(
xterm
.
buffer
.
baseY
,
3
);
assert
.
equal
(
xterm
.
buffer
.
viewportY
,
3
);
assert
.
equal
(
xterm
.
buffer
.
active
.
baseY
,
3
);
assert
.
equal
(
xterm
.
buffer
.
active
.
viewportY
,
3
);
assert
.
equal
(
xterm
.
getSelection
(),
''
);
commandTracker
.
selectToPreviousLine
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录