Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
82532abe
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,发现更多精彩内容 >>
提交
82532abe
编写于
1月 23, 2018
作者:
I
isidor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debug: simplify openConfigFile
上级
40cd234d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
27 addition
and
22 deletion
+27
-22
src/vs/workbench/parts/debug/common/debug.ts
src/vs/workbench/parts/debug/common/debug.ts
+1
-1
src/vs/workbench/parts/debug/electron-browser/debugCommands.ts
...s/workbench/parts/debug/electron-browser/debugCommands.ts
+3
-3
src/vs/workbench/parts/debug/electron-browser/debugConfigurationManager.ts
...parts/debug/electron-browser/debugConfigurationManager.ts
+22
-12
src/vs/workbench/parts/debug/electron-browser/debugService.ts
...vs/workbench/parts/debug/electron-browser/debugService.ts
+1
-6
未找到文件。
src/vs/workbench/parts/debug/common/debug.ts
浏览文件 @
82532abe
...
...
@@ -471,7 +471,7 @@ export interface ILaunch {
/**
* Opens the launch.json file. Creates if it does not exist.
*/
openConfigFile
(
sideBySide
:
boolean
,
type
?:
string
):
TPromise
<
{
editor
:
IEditor
;
configFileCreated
:
boolean
;
}
>
;
openConfigFile
(
sideBySide
:
boolean
,
type
?:
string
):
TPromise
<
IEditor
>
;
}
// Debug service interfaces
...
...
src/vs/workbench/parts/debug/electron-browser/debugCommands.ts
浏览文件 @
82532abe
...
...
@@ -171,9 +171,9 @@ export function registerCommands(): void {
}
const
launch
=
manager
.
getLaunches
().
filter
(
l
=>
l
.
uri
.
toString
()
===
workspaceUri
).
pop
()
||
manager
.
selectedLaunch
;
return
launch
.
openConfigFile
(
false
).
done
(
result
=>
{
if
(
result
.
editor
&&
!
result
.
configFileCreated
)
{
const
codeEditor
=
<
ICodeEditor
>
result
.
editor
.
getControl
();
return
launch
.
openConfigFile
(
false
).
done
(
editor
=>
{
if
(
editor
)
{
const
codeEditor
=
<
ICodeEditor
>
editor
.
getControl
();
if
(
codeEditor
)
{
return
codeEditor
.
getContribution
<
IDebugEditorContribution
>
(
EDITOR_CONTRIBUTION_ID
).
addLaunchConfiguration
();
}
...
...
src/vs/workbench/parts/debug/electron-browser/debugConfigurationManager.ts
浏览文件 @
82532abe
...
...
@@ -9,6 +9,7 @@ import Event, { Emitter } from 'vs/base/common/event';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
first
}
from
'
vs/base/common/arrays
'
;
import
severity
from
'
vs/base/common/severity
'
;
import
{
isLinux
,
isMacintosh
,
isWindows
}
from
'
vs/base/common/platform
'
;
import
*
as
objects
from
'
vs/base/common/objects
'
;
import
uri
from
'
vs/base/common/uri
'
;
...
...
@@ -34,6 +35,7 @@ import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
import
{
IConfigurationResolverService
}
from
'
vs/workbench/services/configurationResolver/common/configurationResolver
'
;
import
{
isCodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
launchSchemaId
}
from
'
vs/workbench/services/configuration/common/configuration
'
;
import
{
IMessageService
}
from
'
vs/platform/message/common/message
'
;
// debuggers extension point
export
const
debuggersExtPoint
=
extensionsRegistry
.
ExtensionsRegistry
.
registerExtensionPoint
<
IRawAdapter
[]
>
(
'
debuggers
'
,
[],
{
...
...
@@ -466,7 +468,8 @@ class Launch implements ILaunch {
@
IFileService
private
fileService
:
IFileService
,
@
IWorkbenchEditorService
protected
editorService
:
IWorkbenchEditorService
,
@
IConfigurationService
protected
configurationService
:
IConfigurationService
,
@
IConfigurationResolverService
private
configurationResolverService
:
IConfigurationResolverService
@
IConfigurationResolverService
private
configurationResolverService
:
IConfigurationResolverService
,
@
IMessageService
private
messageService
:
IMessageService
)
{
// noop
}
...
...
@@ -541,11 +544,11 @@ class Launch implements ILaunch {
return
this
.
configurationResolverService
.
resolveInteractiveVariables
(
result
,
adapter
?
adapter
.
variables
:
null
);
}
public
openConfigFile
(
sideBySide
:
boolean
,
type
?:
string
):
TPromise
<
{
editor
:
IEditor
;
configFileCreated
:
boolean
;
}
>
{
public
openConfigFile
(
sideBySide
:
boolean
,
type
?:
string
):
TPromise
<
IEditor
>
{
const
resource
=
this
.
uri
;
let
configFileCreated
=
false
;
return
this
.
fileService
.
resolveContent
(
resource
).
then
(
content
=>
content
,
err
=>
{
return
this
.
fileService
.
resolveContent
(
resource
).
then
(
content
=>
content
.
value
,
err
=>
{
// launch.json not found: create one by collecting launch configs from debugConfigProviders
...
...
@@ -566,17 +569,17 @@ class Launch implements ILaunch {
configFileCreated
=
true
;
return
this
.
fileService
.
updateContent
(
resource
,
content
).
then
(()
=>
{
// convert string into IContent; see #32135
return
{
value
:
content
}
;
return
content
;
});
});
}).
then
(
content
=>
{
if
(
!
content
)
{
return
{
editor
:
undefined
,
configFileCreated
}
;
return
undefined
;
}
const
index
=
content
.
value
.
indexOf
(
`"
${
this
.
configurationManager
.
selectedName
}
"`
);
const
index
=
content
.
indexOf
(
`"
${
this
.
configurationManager
.
selectedName
}
"`
);
let
startLineNumber
=
1
;
for
(
let
i
=
0
;
i
<
index
;
i
++
)
{
if
(
content
.
value
.
charAt
(
i
)
===
'
\n
'
)
{
if
(
content
.
charAt
(
i
)
===
'
\n
'
)
{
startLineNumber
++
;
}
}
...
...
@@ -590,7 +593,13 @@ class Launch implements ILaunch {
pinned
:
configFileCreated
,
// pin only if config file is created #8727
revealIfVisible
:
true
},
},
sideBySide
).
then
(
editor
=>
({
editor
,
configFileCreated
}));
},
sideBySide
).
then
(
editor
=>
{
if
(
configFileCreated
)
{
this
.
messageService
.
show
(
severity
.
Info
,
nls
.
localize
(
'
NewLaunchConfig
'
,
"
Please set up the launch configuration file for your application.
"
));
}
return
editor
;
});
},
(
error
)
=>
{
throw
new
Error
(
nls
.
localize
(
'
DebugConfig.failed
'
,
"
Unable to create 'launch.json' file inside the '.vscode' folder ({0}).
"
,
error
));
});
...
...
@@ -605,9 +614,10 @@ class WorkspaceLaunch extends Launch implements ILaunch {
@
IWorkbenchEditorService
editorService
:
IWorkbenchEditorService
,
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
IConfigurationResolverService
configurationResolverService
:
IConfigurationResolverService
,
@
IWorkspaceContextService
private
workspaceContextService
:
IWorkspaceContextService
@
IWorkspaceContextService
private
workspaceContextService
:
IWorkspaceContextService
,
@
IMessageService
messageService
:
IMessageService
)
{
super
(
configurationManager
,
undefined
,
fileService
,
editorService
,
configurationService
,
configurationResolverService
);
super
(
configurationManager
,
undefined
,
fileService
,
editorService
,
configurationService
,
configurationResolverService
,
messageService
);
}
get
uri
():
uri
{
...
...
@@ -622,7 +632,7 @@ class WorkspaceLaunch extends Launch implements ILaunch {
return
this
.
configurationService
.
inspect
<
IGlobalConfig
>
(
'
launch
'
).
workspace
;
}
openConfigFile
(
sideBySide
:
boolean
,
type
?:
string
):
TPromise
<
{
editor
:
IEditor
;
configFileCreated
:
boolean
;
},
any
>
{
return
this
.
editorService
.
openEditor
({
resource
:
this
.
workspaceContextService
.
getWorkspace
().
configuration
})
.
then
(
editor
=>
({
editor
,
configFileCreated
:
false
}))
;
openConfigFile
(
sideBySide
:
boolean
,
type
?:
string
):
TPromise
<
IEditor
>
{
return
this
.
editorService
.
openEditor
({
resource
:
this
.
workspaceContextService
.
getWorkspace
().
configuration
});
}
}
src/vs/workbench/parts/debug/electron-browser/debugService.ts
浏览文件 @
82532abe
...
...
@@ -818,12 +818,7 @@ export class DebugService implements debug.IDebugService {
return
undefined
;
}
return
this
.
configurationManager
.
selectedLaunch
.
openConfigFile
(
false
).
then
(
result
=>
{
if
(
result
.
configFileCreated
)
{
this
.
messageService
.
show
(
severity
.
Info
,
nls
.
localize
(
'
NewLaunchConfig
'
,
"
Please set up the launch configuration file for your application. {0}
"
,
err
.
message
));
}
return
undefined
;
});
return
this
.
configurationManager
.
selectedLaunch
.
openConfigFile
(
false
).
then
(
editor
=>
void
0
);
})
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录