Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
53040a1e
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,发现更多精彩内容 >>
提交
53040a1e
编写于
7月 03, 2017
作者:
R
Ryan Adolf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Properly format file path on drop in Windows
上级
ac78ebd8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
83 addition
and
11 deletion
+83
-11
src/vs/workbench/parts/terminal/common/terminal.ts
src/vs/workbench/parts/terminal/common/terminal.ts
+5
-0
src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts
...bench/parts/terminal/electron-browser/terminalInstance.ts
+42
-1
src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts
...orkbench/parts/terminal/electron-browser/terminalPanel.ts
+36
-10
未找到文件。
src/vs/workbench/parts/terminal/common/terminal.ts
浏览文件 @
53040a1e
...
...
@@ -357,4 +357,9 @@ export interface ITerminalInstance {
* Sets the title of the terminal instance.
*/
setTitle
(
title
:
string
):
void
;
/**
* Returns the list of nested shells running in the terminal. This is only implemented for Windows.
*/
getShellList
():
Promise
<
string
[]
>
;
}
src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts
浏览文件 @
53040a1e
...
...
@@ -825,6 +825,47 @@ export class TerminalInstance implements ITerminalInstance {
this
.
_messageTitleListener
=
null
;
}
}
private
static
getChildProcesses
(
pid
:
number
):
Promise
<
{
executable
:
string
,
pid
:
number
}[]
>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
cp
.
execFile
(
'
wmic.exe
'
,
[
'
process
'
,
'
where
'
,
`parentProcessId=
${
pid
}
`
,
'
get
'
,
'
ExecutablePath,ProcessId
'
],
(
err
,
stdout
,
stderr
)
=>
{
if
(
err
)
{
reject
(
err
);
}
else
if
(
stderr
.
length
>
0
)
{
resolve
([]);
// No processes found
}
else
{
resolve
(
stdout
.
split
(
'
\n
'
).
slice
(
1
).
filter
(
str
=>
str
.
length
>
0
).
map
(
str
=>
{
const
s
=
str
.
split
(
'
'
);
return
{
executable
:
s
[
0
],
pid
:
Number
(
s
[
1
])};
}));
}
});
});
}
public
async
getShellList
():
Promise
<
string
[]
>
{
if
(
platform
.
platform
!==
platform
.
Platform
.
Windows
)
{
return
[];
}
const
shells
=
[
'
bash.exe
'
,
'
cmd.exe
'
,
'
powershell.exe
'
];
const
pList
=
[
this
.
_shellLaunchConfig
.
executable
];
let
pid
=
this
.
_processId
;
while
(
pid
!==
null
)
{
const
oldPid
=
pid
;
pid
=
null
;
for
(
const
childproc
of
await
TerminalInstance
.
getChildProcesses
(
oldPid
))
{
if
(
shells
.
indexOf
(
path
.
basename
(
childproc
.
executable
))
!==
-
1
)
{
pList
.
push
(
childproc
.
executable
);
pid
=
childproc
.
pid
;
break
;
}
}
}
return
pList
;
}
}
registerThemingParticipant
((
theme
:
ITheme
,
collector
:
ICssStyleCollector
)
=>
{
...
...
@@ -848,4 +889,4 @@ registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => {
if
(
scrollbarSliderActiveBackgroundColor
)
{
collector
.
addRule
(
`.monaco-workbench .panel.integrated-terminal .xterm .xterm-viewport::-webkit-scrollbar-thumb:active { background-color:
${
scrollbarSliderActiveBackgroundColor
}
; }`
);
}
});
\ No newline at end of file
});
src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts
浏览文件 @
53040a1e
...
...
@@ -232,21 +232,47 @@ export class TerminalPanel extends Panel {
return
;
}
// Check if the file was dragged from the tree explorer
let
uri
=
e
.
dataTransfer
.
getData
(
'
URL
'
);
const
winFormatters
:
[
RegExp
,
(
uri
:
URI
)
=>
string
][]
=
[
// WSL bash
[
/^C:
\\
Windows
\\(
System32|sysnative
)\\
bash.exe$/i
,
uri
=>
'
/mnt/
'
+
uri
.
path
[
1
]
+
uri
.
path
.
substring
(
3
)],
// Git bash
[
/bash.exe$/i
,
uri
=>
uri
.
path
.
substring
(
0
,
2
)
+
uri
.
path
.
substring
(
3
)],
[
/cmd.exe$/i
,
uri
=>
uri
.
path
[
1
].
toUpperCase
()
+
uri
.
path
.
substring
(
2
).
replace
(
/
\/
/g
,
'
\\
'
)],
[
/powershell.exe$/i
,
uri
=>
uri
.
path
[
1
].
toUpperCase
()
+
uri
.
path
.
substring
(
2
).
replace
(
/
\/
/g
,
'
\\
'
)],
];
const
terminal
=
this
.
_terminalService
.
getActiveInstance
();
const
uriForm
=
async
(
uri
:
URI
)
=>
{
if
(
platform
.
isWindows
)
{
const
shells
=
await
terminal
.
getShellList
();
const
shell
=
shells
[
shells
.
length
-
1
];
for
(
const
formatter
of
winFormatters
)
{
if
(
formatter
[
0
].
test
(
shell
))
{
return
formatter
[
1
](
uri
);
}
}
}
return
uri
.
path
;
};
const
uri
=
e
.
dataTransfer
.
getData
(
'
URL
'
);
let
urip
=
Promise
.
resolve
(
uri
);
if
(
uri
)
{
uri
=
URI
.
parse
(
uri
).
path
;
uri
p
=
uriForm
(
URI
.
parse
(
uri
))
;
}
else
if
(
e
.
dataTransfer
.
files
.
length
>
0
)
{
// Check if the file was dragged from the filesystem
uri
=
URI
.
file
(
e
.
dataTransfer
.
files
[
0
].
path
).
path
;
uri
p
=
uriForm
(
URI
.
file
(
e
.
dataTransfer
.
files
[
0
].
path
))
;
}
if
(
!
uri
)
{
return
;
}
const
terminal
=
this
.
_terminalService
.
getActiveInstance
(
);
terminal
.
sendText
(
this
.
_preparePathForTerminal
(
uri
),
false
);
urip
.
then
(
uri
=>
{
if
(
!
uri
)
{
return
;
}
terminal
.
sendText
(
this
.
_preparePathForTerminal
(
uri
),
false
);
}
);
}
}));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录