Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
d9f1563e
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d9f1563e
编写于
12月 10, 2018
作者:
N
Noj Vek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes #27107 - User terminal's cwd for links
上级
26fa59cd
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
35 addition
and
13 deletion
+35
-13
src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts
...bench/parts/terminal/electron-browser/terminalInstance.ts
+23
-1
src/vs/workbench/parts/terminal/electron-browser/terminalLinkHandler.ts
...ch/parts/terminal/electron-browser/terminalLinkHandler.ts
+9
-9
src/vs/workbench/parts/terminal/test/electron-browser/terminalLinkHandler.test.ts
...erminal/test/electron-browser/terminalLinkHandler.test.ts
+3
-3
未找到文件。
src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts
浏览文件 @
d9f1563e
...
...
@@ -10,6 +10,7 @@ import * as dom from 'vs/base/browser/dom';
import
*
as
paths
from
'
vs/base/common/paths
'
;
import
*
as
os
from
'
os
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
debounce
}
from
'
vs/base/common/decorators
'
;
import
{
WindowsShellHelper
}
from
'
vs/workbench/parts/terminal/node/windowsShellHelper
'
;
import
{
Terminal
as
XTermTerminal
,
ISearchOptions
}
from
'
vscode-xterm
'
;
import
{
IContextKeyService
,
IContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
...
...
@@ -17,6 +18,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import
{
IPanelService
}
from
'
vs/workbench/services/panel/common/panelService
'
;
import
{
ITerminalInstance
,
KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED
,
TERMINAL_PANEL_ID
,
IShellLaunchConfig
,
ITerminalProcessManager
,
ProcessState
,
NEVER_MEASURE_RENDER_TIME_STORAGE_KEY
,
ITerminalDimensions
}
from
'
vs/workbench/parts/terminal/common/terminal
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
StandardKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
TabFocus
}
from
'
vs/editor/common/config/commonEditorConfig
'
;
import
{
TerminalConfigHelper
}
from
'
vs/workbench/parts/terminal/electron-browser/terminalConfigHelper
'
;
...
...
@@ -310,13 +312,15 @@ export class TerminalInstance implements ITerminalInstance {
}
this
.
_xterm
.
winptyCompatInit
();
this
.
_xterm
.
on
(
'
linefeed
'
,
()
=>
this
.
_onLineFeed
());
this
.
_xterm
.
on
(
'
key
'
,
(
key
,
ev
)
=>
this
.
_onKey
(
key
,
ev
));
if
(
this
.
_processManager
)
{
this
.
_processManager
.
onProcessData
(
data
=>
this
.
_onProcessData
(
data
));
this
.
_xterm
.
on
(
'
data
'
,
data
=>
this
.
_processManager
.
write
(
data
));
// TODO: How does the cwd work on detached processes?
this
.
_linkHandler
=
this
.
_instantiationService
.
createInstance
(
TerminalLinkHandler
,
this
.
_xterm
,
platform
.
platform
);
this
.
processReady
.
then
(()
=>
{
this
.
_linkHandler
.
initial
Cwd
=
this
.
_processManager
.
initialCwd
;
this
.
_linkHandler
.
process
Cwd
=
this
.
_processManager
.
initialCwd
;
});
}
this
.
_xterm
.
on
(
'
focus
'
,
()
=>
this
.
_onFocus
.
fire
(
this
));
...
...
@@ -940,6 +944,24 @@ export class TerminalInstance implements ITerminalInstance {
this
.
_onLineData
.
fire
(
lineData
);
}
private
_onKey
(
key
:
string
,
ev
:
KeyboardEvent
)
{
const
event
=
new
StandardKeyboardEvent
(
ev
);
if
(
event
.
equals
(
KeyCode
.
Enter
))
{
this
.
_updateProcessCwd
();
}
}
@
debounce
(
2000
)
private
async
_updateProcessCwd
():
Promise
<
string
>
{
// reset cwd if it has changed, so file based url paths can be resolved
const
cwd
=
await
this
.
getCwd
();
if
(
cwd
)
{
this
.
_linkHandler
.
processCwd
=
cwd
;
}
return
cwd
;
}
public
updateConfig
():
void
{
const
config
=
this
.
_configHelper
.
config
;
this
.
_setCursorBlink
(
config
.
cursorBlinking
);
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalLinkHandler.ts
浏览文件 @
d9f1563e
...
...
@@ -60,7 +60,7 @@ export class TerminalLinkHandler {
private
_hoverDisposables
:
IDisposable
[]
=
[];
private
_mouseMoveDisposable
:
IDisposable
;
private
_widgetManager
:
TerminalWidgetManager
;
private
_
initial
Cwd
:
string
;
private
_
process
Cwd
:
string
;
private
_localLinkPattern
:
RegExp
;
constructor
(
...
...
@@ -82,8 +82,8 @@ export class TerminalLinkHandler {
this
.
_widgetManager
=
widgetManager
;
}
public
set
initialCwd
(
initial
Cwd
:
string
)
{
this
.
_
initialCwd
=
initial
Cwd
;
public
set
processCwd
(
process
Cwd
:
string
)
{
this
.
_
processCwd
=
process
Cwd
;
}
public
registerCustomLinkHandler
(
regex
:
RegExp
,
handler
:
(
uri
:
string
)
=>
void
,
matchIndex
?:
number
,
validationCallback
?:
XtermLinkMatcherValidationCallback
):
number
{
...
...
@@ -227,20 +227,20 @@ export class TerminalLinkHandler {
// Resolve relative paths (.\a, ..\a, ~\a, a\b)
if
(
!
link
.
match
(
'
^
'
+
winDrivePrefix
))
{
if
(
!
this
.
_
initial
Cwd
)
{
if
(
!
this
.
_
process
Cwd
)
{
// Abort if no workspace is open
return
null
;
}
link
=
path
.
join
(
this
.
_
initial
Cwd
,
link
);
link
=
path
.
join
(
this
.
_
process
Cwd
,
link
);
}
}
// Resolve workspace path . | .. | <relative_path> -> <path>/. | <path>/.. | <path>/<relative_path>
else
if
(
link
.
charAt
(
0
)
!==
'
/
'
&&
link
.
charAt
(
0
)
!==
'
~
'
)
{
if
(
!
this
.
_
initial
Cwd
)
{
if
(
!
this
.
_
process
Cwd
)
{
// Abort if no workspace is open
return
null
;
}
link
=
path
.
join
(
this
.
_
initial
Cwd
,
link
);
link
=
path
.
join
(
this
.
_
process
Cwd
,
link
);
}
return
link
;
}
...
...
@@ -256,7 +256,7 @@ export class TerminalLinkHandler {
return
Promise
.
resolve
(
void
0
);
}
//
Open an editor if the path exists
//
Ensure the file exists on disk, so an editor can be opened after clicking it
return
pfs
.
fileExists
(
linkUrl
).
then
(
isFile
=>
{
if
(
!
isFile
)
{
return
null
;
...
...
@@ -312,4 +312,4 @@ export class TerminalLinkHandler {
export
interface
LineColumnInfo
{
lineNumber
:
number
;
columnNumber
:
number
;
}
\ No newline at end of file
}
src/vs/workbench/parts/terminal/test/electron-browser/terminalLinkHandler.test.ts
浏览文件 @
d9f1563e
...
...
@@ -170,7 +170,7 @@ suite('Workbench - TerminalLinkHandler', () => {
suite
(
'
preprocessPath
'
,
()
=>
{
test
(
'
Windows
'
,
()
=>
{
const
linkHandler
=
new
TestTerminalLinkHandler
(
new
TestXterm
(),
Platform
.
Windows
,
null
,
null
,
null
,
null
);
linkHandler
.
initial
Cwd
=
'
C:
\\
base
'
;
linkHandler
.
process
Cwd
=
'
C:
\\
base
'
;
let
stub
=
sinon
.
stub
(
path
,
'
join
'
,
function
(
arg1
:
string
,
arg2
:
string
)
{
return
arg1
+
'
\\
'
+
arg2
;
...
...
@@ -183,7 +183,7 @@ suite('Workbench - TerminalLinkHandler', () => {
});
test
(
'
Windows - spaces
'
,
()
=>
{
const
linkHandler
=
new
TestTerminalLinkHandler
(
new
TestXterm
(),
Platform
.
Windows
,
null
,
null
,
null
,
null
);
linkHandler
.
initial
Cwd
=
'
C:
\\
base dir
'
;
linkHandler
.
process
Cwd
=
'
C:
\\
base dir
'
;
let
stub
=
sinon
.
stub
(
path
,
'
join
'
,
function
(
arg1
:
string
,
arg2
:
string
)
{
return
arg1
+
'
\\
'
+
arg2
;
...
...
@@ -197,7 +197,7 @@ suite('Workbench - TerminalLinkHandler', () => {
test
(
'
Linux
'
,
()
=>
{
const
linkHandler
=
new
TestTerminalLinkHandler
(
new
TestXterm
(),
Platform
.
Linux
,
null
,
null
,
null
,
null
);
linkHandler
.
initial
Cwd
=
'
/base
'
;
linkHandler
.
process
Cwd
=
'
/base
'
;
let
stub
=
sinon
.
stub
(
path
,
'
join
'
,
function
(
arg1
:
string
,
arg2
:
string
)
{
return
arg1
+
'
/
'
+
arg2
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录