Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
fe169ce4
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,发现更多精彩内容 >>
提交
fe169ce4
编写于
3月 04, 2019
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move terminalLinkHandler, electron-browser->browser
Part of #69115
上级
47977b99
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
62 addition
and
16 deletion
+62
-16
src/tsconfig.strictNullChecks.json
src/tsconfig.strictNullChecks.json
+1
-1
src/vs/workbench/contrib/terminal/browser/terminalLinkHandler.ts
...workbench/contrib/terminal/browser/terminalLinkHandler.ts
+52
-6
src/vs/workbench/contrib/terminal/electron-browser/terminalInstance.ts
...nch/contrib/terminal/electron-browser/terminalInstance.ts
+1
-1
src/vs/workbench/contrib/terminal/test/electron-browser/terminalLinkHandler.test.ts
...erminal/test/electron-browser/terminalLinkHandler.test.ts
+8
-8
未找到文件。
src/tsconfig.strictNullChecks.json
浏览文件 @
fe169ce4
...
@@ -279,6 +279,7 @@
...
@@ -279,6 +279,7 @@
"./vs/workbench/contrib/surveys/electron-browser/nps.contribution.ts"
,
"./vs/workbench/contrib/surveys/electron-browser/nps.contribution.ts"
,
"./vs/workbench/contrib/terminal/browser/terminalFindWidget.ts"
,
"./vs/workbench/contrib/terminal/browser/terminalFindWidget.ts"
,
"./vs/workbench/contrib/terminal/browser/terminalLinkHandler.ts"
,
"./vs/workbench/contrib/terminal/browser/terminalQuickOpen.ts"
,
"./vs/workbench/contrib/terminal/browser/terminalQuickOpen.ts"
,
"./vs/workbench/contrib/terminal/browser/terminalTab.ts"
,
"./vs/workbench/contrib/terminal/browser/terminalTab.ts"
,
"./vs/workbench/contrib/terminal/browser/terminalWidgetManager.ts"
,
"./vs/workbench/contrib/terminal/browser/terminalWidgetManager.ts"
,
...
@@ -290,7 +291,6 @@
...
@@ -290,7 +291,6 @@
"./vs/workbench/contrib/terminal/electron-browser/terminalActions.ts"
,
"./vs/workbench/contrib/terminal/electron-browser/terminalActions.ts"
,
"./vs/workbench/contrib/terminal/electron-browser/terminalConfigHelper.ts"
,
"./vs/workbench/contrib/terminal/electron-browser/terminalConfigHelper.ts"
,
"./vs/workbench/contrib/terminal/electron-browser/terminalInstance.ts"
,
"./vs/workbench/contrib/terminal/electron-browser/terminalInstance.ts"
,
"./vs/workbench/contrib/terminal/electron-browser/terminalLinkHandler.ts"
,
"./vs/workbench/contrib/terminal/electron-browser/terminalPanel.ts"
,
"./vs/workbench/contrib/terminal/electron-browser/terminalPanel.ts"
,
"./vs/workbench/contrib/terminal/electron-browser/terminalProcessManager.ts"
,
"./vs/workbench/contrib/terminal/electron-browser/terminalProcessManager.ts"
,
"./vs/workbench/contrib/terminal/node/terminal.ts"
,
"./vs/workbench/contrib/terminal/node/terminal.ts"
,
...
...
src/vs/workbench/contrib/terminal/
electron-
browser/terminalLinkHandler.ts
→
src/vs/workbench/contrib/terminal/browser/terminalLinkHandler.ts
浏览文件 @
fe169ce4
...
@@ -6,8 +6,7 @@
...
@@ -6,8 +6,7 @@
import
*
as
nls
from
'
vs/nls
'
;
import
*
as
nls
from
'
vs/nls
'
;
import
*
as
path
from
'
vs/base/common/path
'
;
import
*
as
path
from
'
vs/base/common/path
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
*
as
pfs
from
'
vs/base/node/pfs
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
URI
as
Uri
}
from
'
vs/base/common/uri
'
;
import
{
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
TerminalWidgetManager
}
from
'
vs/workbench/contrib/terminal/browser/terminalWidgetManager
'
;
import
{
TerminalWidgetManager
}
from
'
vs/workbench/contrib/terminal/browser/terminalWidgetManager
'
;
...
@@ -15,7 +14,53 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
...
@@ -15,7 +14,53 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import
{
ITerminalService
}
from
'
vs/workbench/contrib/terminal/common/terminal
'
;
import
{
ITerminalService
}
from
'
vs/workbench/contrib/terminal/common/terminal
'
;
import
{
ITextEditorSelection
}
from
'
vs/platform/editor/common/editor
'
;
import
{
ITextEditorSelection
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
ILinkMatcherOptions
}
from
'
vscode-xterm
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
// Since importing from vscode-xterm would be a layer breakage here the type is copied inline
// import { ILinkMatcherOptions } from 'vscode-xterm';
/**
* An object containing options for a link matcher.
*/
export
interface
ILinkMatcherOptions
{
/**
* The index of the link from the regex.match(text) call. This defaults to 0
* (for regular expressions without capture groups).
*/
matchIndex
?:
number
;
/**
* A callback that validates whether to create an individual link, pass
* whether the link is valid to the callback.
*/
validationCallback
?:
(
uri
:
string
,
callback
:
(
isValid
:
boolean
)
=>
void
)
=>
void
;
/**
* A callback that fires when the mouse hovers over a link for a moment.
*/
tooltipCallback
?:
(
event
:
MouseEvent
,
uri
:
string
)
=>
boolean
|
void
;
/**
* A callback that fires when the mouse leaves a link. Note that this can
* happen even when tooltipCallback hasn't fired for the link yet.
*/
leaveCallback
?:
(
event
:
MouseEvent
,
uri
:
string
)
=>
boolean
|
void
;
/**
* The priority of the link matcher, this defines the order in which the link
* matcher is evaluated relative to others, from highest to lowest. The
* default value is 0.
*/
priority
?:
number
;
/**
* A callback that fires when the mousedown and click events occur that
* determines whether a link will be activated upon click. This enables
* only activating a link when a certain modifier is held down, if not the
* mouse event will continue propagation (eg. double click to select word).
*/
willLinkActivate
?:
(
event
:
MouseEvent
,
uri
:
string
)
=>
boolean
;
}
const
pathPrefix
=
'
(
\\
.
\\
.?|
\\
~)
'
;
const
pathPrefix
=
'
(
\\
.
\\
.?|
\\
~)
'
;
const
pathSeparatorClause
=
'
\\
/
'
;
const
pathSeparatorClause
=
'
\\
/
'
;
...
@@ -74,6 +119,7 @@ export class TerminalLinkHandler {
...
@@ -74,6 +119,7 @@ export class TerminalLinkHandler {
@
IEditorService
private
readonly
_editorService
:
IEditorService
,
@
IEditorService
private
readonly
_editorService
:
IEditorService
,
@
IConfigurationService
private
readonly
_configurationService
:
IConfigurationService
,
@
IConfigurationService
private
readonly
_configurationService
:
IConfigurationService
,
@
ITerminalService
private
readonly
_terminalService
:
ITerminalService
,
@
ITerminalService
private
readonly
_terminalService
:
ITerminalService
,
@
IFileService
private
readonly
_fileService
:
IFileService
)
{
)
{
const
baseLocalLinkClause
=
_platform
===
platform
.
Platform
.
Windows
?
winLocalLinkClause
:
unixLocalLinkClause
;
const
baseLocalLinkClause
=
_platform
===
platform
.
Platform
.
Windows
?
winLocalLinkClause
:
unixLocalLinkClause
;
// Append line and column number regex
// Append line and column number regex
...
@@ -203,7 +249,7 @@ export class TerminalLinkHandler {
...
@@ -203,7 +249,7 @@ export class TerminalLinkHandler {
if
(
!
normalizedUrl
)
{
if
(
!
normalizedUrl
)
{
return
Promise
.
resolve
(
null
);
return
Promise
.
resolve
(
null
);
}
}
const
resource
=
U
ri
.
file
(
normalizedUrl
);
const
resource
=
U
RI
.
file
(
normalizedUrl
);
const
lineColumnInfo
:
LineColumnInfo
=
this
.
extractLineColumnInfo
(
link
);
const
lineColumnInfo
:
LineColumnInfo
=
this
.
extractLineColumnInfo
(
link
);
const
selection
:
ITextEditorSelection
=
{
const
selection
:
ITextEditorSelection
=
{
startLineNumber
:
lineColumnInfo
.
lineNumber
,
startLineNumber
:
lineColumnInfo
.
lineNumber
,
...
@@ -223,7 +269,7 @@ export class TerminalLinkHandler {
...
@@ -223,7 +269,7 @@ export class TerminalLinkHandler {
}
}
private
_handleHypertextLink
(
url
:
string
):
void
{
private
_handleHypertextLink
(
url
:
string
):
void
{
const
uri
=
U
ri
.
parse
(
url
);
const
uri
=
U
RI
.
parse
(
url
);
this
.
_openerService
.
open
(
uri
);
this
.
_openerService
.
open
(
uri
);
}
}
...
@@ -288,7 +334,7 @@ export class TerminalLinkHandler {
...
@@ -288,7 +334,7 @@ export class TerminalLinkHandler {
}
}
// Ensure the file exists on disk, so an editor can be opened after clicking it
// Ensure the file exists on disk, so an editor can be opened after clicking it
return
pfs
.
fileExists
(
linkUrl
).
then
(
isFile
=>
{
return
this
.
_fileService
.
existsFile
(
URI
.
file
(
linkUrl
)
).
then
(
isFile
=>
{
if
(
!
isFile
)
{
if
(
!
isFile
)
{
return
null
;
return
null
;
}
}
...
...
src/vs/workbench/contrib/terminal/electron-browser/terminalInstance.ts
浏览文件 @
fe169ce4
...
@@ -31,7 +31,7 @@ import { IShellLaunchConfig, ITerminalDimensions, ITerminalInstance, ITerminalPr
...
@@ -31,7 +31,7 @@ import { IShellLaunchConfig, ITerminalDimensions, ITerminalInstance, ITerminalPr
import
{
ansiColorIdentifiers
,
TERMINAL_BACKGROUND_COLOR
,
TERMINAL_CURSOR_BACKGROUND_COLOR
,
TERMINAL_CURSOR_FOREGROUND_COLOR
,
TERMINAL_FOREGROUND_COLOR
,
TERMINAL_SELECTION_BACKGROUND_COLOR
}
from
'
vs/workbench/contrib/terminal/common/terminalColorRegistry
'
;
import
{
ansiColorIdentifiers
,
TERMINAL_BACKGROUND_COLOR
,
TERMINAL_CURSOR_BACKGROUND_COLOR
,
TERMINAL_CURSOR_FOREGROUND_COLOR
,
TERMINAL_FOREGROUND_COLOR
,
TERMINAL_SELECTION_BACKGROUND_COLOR
}
from
'
vs/workbench/contrib/terminal/common/terminalColorRegistry
'
;
import
{
TERMINAL_COMMAND_ID
}
from
'
vs/workbench/contrib/terminal/common/terminalCommands
'
;
import
{
TERMINAL_COMMAND_ID
}
from
'
vs/workbench/contrib/terminal/common/terminalCommands
'
;
import
{
TerminalConfigHelper
}
from
'
vs/workbench/contrib/terminal/electron-browser/terminalConfigHelper
'
;
import
{
TerminalConfigHelper
}
from
'
vs/workbench/contrib/terminal/electron-browser/terminalConfigHelper
'
;
import
{
TerminalLinkHandler
}
from
'
vs/workbench/contrib/terminal/
electron-
browser/terminalLinkHandler
'
;
import
{
TerminalLinkHandler
}
from
'
vs/workbench/contrib/terminal/browser/terminalLinkHandler
'
;
import
{
TerminalProcessManager
}
from
'
vs/workbench/contrib/terminal/electron-browser/terminalProcessManager
'
;
import
{
TerminalProcessManager
}
from
'
vs/workbench/contrib/terminal/electron-browser/terminalProcessManager
'
;
import
{
TerminalCommandTracker
}
from
'
vs/workbench/contrib/terminal/node/terminalCommandTracker
'
;
import
{
TerminalCommandTracker
}
from
'
vs/workbench/contrib/terminal/node/terminalCommandTracker
'
;
import
{
WindowsShellHelper
}
from
'
vs/workbench/contrib/terminal/node/windowsShellHelper
'
;
import
{
WindowsShellHelper
}
from
'
vs/workbench/contrib/terminal/node/windowsShellHelper
'
;
...
...
src/vs/workbench/contrib/terminal/test/electron-browser/terminalLinkHandler.test.ts
浏览文件 @
fe169ce4
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
import
*
as
assert
from
'
assert
'
;
import
*
as
assert
from
'
assert
'
;
import
{
Platform
}
from
'
vs/base/common/platform
'
;
import
{
Platform
}
from
'
vs/base/common/platform
'
;
import
{
TerminalLinkHandler
,
LineColumnInfo
}
from
'
vs/workbench/contrib/terminal/
electron-
browser/terminalLinkHandler
'
;
import
{
TerminalLinkHandler
,
LineColumnInfo
}
from
'
vs/workbench/contrib/terminal/browser/terminalLinkHandler
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
*
as
path
from
'
vs/base/common/path
'
;
import
*
as
path
from
'
vs/base/common/path
'
;
import
*
as
sinon
from
'
sinon
'
;
import
*
as
sinon
from
'
sinon
'
;
...
@@ -39,7 +39,7 @@ interface LinkFormatInfo {
...
@@ -39,7 +39,7 @@ interface LinkFormatInfo {
suite
(
'
Workbench - TerminalLinkHandler
'
,
()
=>
{
suite
(
'
Workbench - TerminalLinkHandler
'
,
()
=>
{
suite
(
'
localLinkRegex
'
,
()
=>
{
suite
(
'
localLinkRegex
'
,
()
=>
{
test
(
'
Windows
'
,
()
=>
{
test
(
'
Windows
'
,
()
=>
{
const
terminalLinkHandler
=
new
TestTerminalLinkHandler
(
new
TestXterm
(),
Platform
.
Windows
,
null
!
,
null
!
,
null
!
,
null
!
);
const
terminalLinkHandler
=
new
TestTerminalLinkHandler
(
new
TestXterm
(),
Platform
.
Windows
,
null
!
,
null
!
,
null
!
,
null
!
,
null
!
);
function
testLink
(
link
:
string
,
linkUrl
:
string
,
lineNo
?:
string
,
columnNo
?:
string
)
{
function
testLink
(
link
:
string
,
linkUrl
:
string
,
lineNo
?:
string
,
columnNo
?:
string
)
{
assert
.
equal
(
terminalLinkHandler
.
extractLinkUrl
(
link
),
linkUrl
);
assert
.
equal
(
terminalLinkHandler
.
extractLinkUrl
(
link
),
linkUrl
);
assert
.
equal
(
terminalLinkHandler
.
extractLinkUrl
(
`:
${
link
}
:`
),
linkUrl
);
assert
.
equal
(
terminalLinkHandler
.
extractLinkUrl
(
`:
${
link
}
:`
),
linkUrl
);
...
@@ -111,7 +111,7 @@ suite('Workbench - TerminalLinkHandler', () => {
...
@@ -111,7 +111,7 @@ suite('Workbench - TerminalLinkHandler', () => {
});
});
test
(
'
Linux
'
,
()
=>
{
test
(
'
Linux
'
,
()
=>
{
const
terminalLinkHandler
=
new
TestTerminalLinkHandler
(
new
TestXterm
(),
Platform
.
Linux
,
null
!
,
null
!
,
null
!
,
null
!
);
const
terminalLinkHandler
=
new
TestTerminalLinkHandler
(
new
TestXterm
(),
Platform
.
Linux
,
null
!
,
null
!
,
null
!
,
null
!
,
null
!
);
function
testLink
(
link
:
string
,
linkUrl
:
string
,
lineNo
?:
string
,
columnNo
?:
string
)
{
function
testLink
(
link
:
string
,
linkUrl
:
string
,
lineNo
?:
string
,
columnNo
?:
string
)
{
assert
.
equal
(
terminalLinkHandler
.
extractLinkUrl
(
link
),
linkUrl
);
assert
.
equal
(
terminalLinkHandler
.
extractLinkUrl
(
link
),
linkUrl
);
assert
.
equal
(
terminalLinkHandler
.
extractLinkUrl
(
`:
${
link
}
:`
),
linkUrl
);
assert
.
equal
(
terminalLinkHandler
.
extractLinkUrl
(
`:
${
link
}
:`
),
linkUrl
);
...
@@ -175,7 +175,7 @@ suite('Workbench - TerminalLinkHandler', () => {
...
@@ -175,7 +175,7 @@ suite('Workbench - TerminalLinkHandler', () => {
suite
(
'
preprocessPath
'
,
()
=>
{
suite
(
'
preprocessPath
'
,
()
=>
{
test
(
'
Windows
'
,
()
=>
{
test
(
'
Windows
'
,
()
=>
{
const
linkHandler
=
new
TestTerminalLinkHandler
(
new
TestXterm
(),
Platform
.
Windows
,
null
!
,
null
!
,
null
!
,
null
!
);
const
linkHandler
=
new
TestTerminalLinkHandler
(
new
TestXterm
(),
Platform
.
Windows
,
null
!
,
null
!
,
null
!
,
null
!
,
null
!
);
linkHandler
.
processCwd
=
'
C:
\\
base
'
;
linkHandler
.
processCwd
=
'
C:
\\
base
'
;
let
stub
=
sinon
.
stub
(
path
,
'
join
'
,
function
(
arg1
:
string
,
arg2
:
string
)
{
let
stub
=
sinon
.
stub
(
path
,
'
join
'
,
function
(
arg1
:
string
,
arg2
:
string
)
{
...
@@ -188,7 +188,7 @@ suite('Workbench - TerminalLinkHandler', () => {
...
@@ -188,7 +188,7 @@ suite('Workbench - TerminalLinkHandler', () => {
stub
.
restore
();
stub
.
restore
();
});
});
test
(
'
Windows - spaces
'
,
()
=>
{
test
(
'
Windows - spaces
'
,
()
=>
{
const
linkHandler
=
new
TestTerminalLinkHandler
(
new
TestXterm
(),
Platform
.
Windows
,
null
!
,
null
!
,
null
!
,
null
!
);
const
linkHandler
=
new
TestTerminalLinkHandler
(
new
TestXterm
(),
Platform
.
Windows
,
null
!
,
null
!
,
null
!
,
null
!
,
null
!
);
linkHandler
.
processCwd
=
'
C:
\\
base dir
'
;
linkHandler
.
processCwd
=
'
C:
\\
base dir
'
;
let
stub
=
sinon
.
stub
(
path
,
'
join
'
,
function
(
arg1
:
string
,
arg2
:
string
)
{
let
stub
=
sinon
.
stub
(
path
,
'
join
'
,
function
(
arg1
:
string
,
arg2
:
string
)
{
...
@@ -202,7 +202,7 @@ suite('Workbench - TerminalLinkHandler', () => {
...
@@ -202,7 +202,7 @@ suite('Workbench - TerminalLinkHandler', () => {
});
});
test
(
'
Linux
'
,
()
=>
{
test
(
'
Linux
'
,
()
=>
{
const
linkHandler
=
new
TestTerminalLinkHandler
(
new
TestXterm
(),
Platform
.
Linux
,
null
!
,
null
!
,
null
!
,
null
!
);
const
linkHandler
=
new
TestTerminalLinkHandler
(
new
TestXterm
(),
Platform
.
Linux
,
null
!
,
null
!
,
null
!
,
null
!
,
null
!
);
linkHandler
.
processCwd
=
'
/base
'
;
linkHandler
.
processCwd
=
'
/base
'
;
let
stub
=
sinon
.
stub
(
path
,
'
join
'
,
function
(
arg1
:
string
,
arg2
:
string
)
{
let
stub
=
sinon
.
stub
(
path
,
'
join
'
,
function
(
arg1
:
string
,
arg2
:
string
)
{
...
@@ -216,7 +216,7 @@ suite('Workbench - TerminalLinkHandler', () => {
...
@@ -216,7 +216,7 @@ suite('Workbench - TerminalLinkHandler', () => {
});
});
test
(
'
No Workspace
'
,
()
=>
{
test
(
'
No Workspace
'
,
()
=>
{
const
linkHandler
=
new
TestTerminalLinkHandler
(
new
TestXterm
(),
Platform
.
Linux
,
null
!
,
null
!
,
null
!
,
null
!
);
const
linkHandler
=
new
TestTerminalLinkHandler
(
new
TestXterm
(),
Platform
.
Linux
,
null
!
,
null
!
,
null
!
,
null
!
,
null
!
);
assert
.
equal
(
linkHandler
.
preprocessPath
(
'
./src/file1
'
),
null
);
assert
.
equal
(
linkHandler
.
preprocessPath
(
'
./src/file1
'
),
null
);
assert
.
equal
(
linkHandler
.
preprocessPath
(
'
src/file2
'
),
null
);
assert
.
equal
(
linkHandler
.
preprocessPath
(
'
src/file2
'
),
null
);
...
@@ -226,7 +226,7 @@ suite('Workbench - TerminalLinkHandler', () => {
...
@@ -226,7 +226,7 @@ suite('Workbench - TerminalLinkHandler', () => {
test
(
'
gitDiffLinkRegex
'
,
()
=>
{
test
(
'
gitDiffLinkRegex
'
,
()
=>
{
// The platform is irrelevant because the links generated by Git are the same format regardless of platform
// The platform is irrelevant because the links generated by Git are the same format regardless of platform
const
linkHandler
=
new
TestTerminalLinkHandler
(
new
TestXterm
(),
Platform
.
Linux
,
null
!
,
null
!
,
null
!
,
null
!
);
const
linkHandler
=
new
TestTerminalLinkHandler
(
new
TestXterm
(),
Platform
.
Linux
,
null
!
,
null
!
,
null
!
,
null
!
,
null
!
);
function
assertAreGoodMatches
(
matches
:
RegExpMatchArray
|
null
)
{
function
assertAreGoodMatches
(
matches
:
RegExpMatchArray
|
null
)
{
if
(
matches
)
{
if
(
matches
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录