Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
c59da6a4
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,发现更多精彩内容 >>
提交
c59da6a4
编写于
1月 17, 2017
作者:
C
Christof Marti
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Acquire models in input
上级
8ef8adb3
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
201 addition
and
99 deletion
+201
-99
src/vs/workbench/parts/walkThrough/common/walkThroughInput.ts
...vs/workbench/parts/walkThrough/common/walkThroughInput.ts
+0
-27
src/vs/workbench/parts/walkThrough/electron-browser/editor/editorWalkThrough.ts
.../walkThrough/electron-browser/editor/editorWalkThrough.ts
+1
-1
src/vs/workbench/parts/walkThrough/electron-browser/walkThrough.contribution.ts
.../walkThrough/electron-browser/walkThrough.contribution.ts
+1
-1
src/vs/workbench/parts/walkThrough/electron-browser/walkThroughPart.ts
...nch/parts/walkThrough/electron-browser/walkThroughPart.ts
+34
-69
src/vs/workbench/parts/walkThrough/node/walkThroughInput.ts
src/vs/workbench/parts/walkThrough/node/walkThroughInput.ts
+164
-0
src/vs/workbench/parts/welcomePage/electron-browser/welcomePage.ts
...rkbench/parts/welcomePage/electron-browser/welcomePage.ts
+1
-1
未找到文件。
src/vs/workbench/parts/walkThrough/common/walkThroughInput.ts
已删除
100644 → 0
浏览文件 @
8ef8adb3
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
ResourceEditorInput
}
from
'
vs/workbench/common/editor/resourceEditorInput
'
;
import
{
ITextModelResolverService
}
from
'
vs/editor/common/services/resolverService
'
;
export
class
WalkThroughInput
extends
ResourceEditorInput
{
// just a marker class
constructor
(
name
:
string
,
description
:
string
,
resource
:
URI
,
public
readonly
onReady
:
(
container
:
HTMLElement
)
=>
void
,
@
ITextModelResolverService
textModelResolverService
:
ITextModelResolverService
)
{
super
(
name
,
description
,
resource
,
textModelResolverService
);
}
getResource
():
URI
{
return
this
.
resource
;
}
}
src/vs/workbench/parts/walkThrough/electron-browser/editor/editorWalkThrough.ts
浏览文件 @
c59da6a4
...
...
@@ -11,7 +11,7 @@ import { Action } from 'vs/base/common/actions';
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
WalkThroughInput
}
from
'
vs/workbench/parts/walkThrough/
common
/walkThroughInput
'
;
import
{
WalkThroughInput
}
from
'
vs/workbench/parts/walkThrough/
node
/walkThroughInput
'
;
import
{
WALK_THROUGH_SCHEME
}
from
'
vs/workbench/parts/walkThrough/electron-browser/walkThroughContentProvider
'
;
export
class
EditorWalkThroughAction
extends
Action
{
...
...
src/vs/workbench/parts/walkThrough/electron-browser/walkThrough.contribution.ts
浏览文件 @
c59da6a4
...
...
@@ -5,7 +5,7 @@
'
use strict
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
WalkThroughInput
}
from
'
vs/workbench/parts/walkThrough/
common
/walkThroughInput
'
;
import
{
WalkThroughInput
}
from
'
vs/workbench/parts/walkThrough/
node
/walkThroughInput
'
;
import
{
WalkThroughPart
}
from
'
vs/workbench/parts/walkThrough/electron-browser/walkThroughPart
'
;
import
{
WalkThroughContentProvider
}
from
'
vs/workbench/parts/walkThrough/electron-browser/walkThroughContentProvider
'
;
import
{
EditorWalkThroughAction
}
from
'
vs/workbench/parts/walkThrough/electron-browser/editor/editorWalkThrough
'
;
...
...
src/vs/workbench/parts/walkThrough/electron-browser/walkThroughPart.ts
浏览文件 @
c59da6a4
...
...
@@ -12,26 +12,22 @@ import * as strings from 'vs/base/common/strings';
import
URI
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
DefaultConfig
}
from
'
vs/editor/common/config/defaultConfig
'
;
import
{
IEditorOptions
,
IModel
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IEditorOptions
}
from
'
vs/editor/common/editorCommon
'
;
import
{
$
,
Dimension
,
Builder
}
from
'
vs/base/browser/builder
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
EditorOptions
}
from
'
vs/workbench/common/editor
'
;
import
{
BaseEditor
}
from
'
vs/workbench/browser/parts/editor/baseEditor
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
WalkThroughInput
}
from
'
vs/workbench/parts/walkThrough/
common
/walkThroughInput
'
;
import
{
WalkThroughInput
}
from
'
vs/workbench/parts/walkThrough/
node
/walkThroughInput
'
;
import
{
IThemeService
}
from
'
vs/workbench/services/themes/common/themeService
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
marked
}
from
'
vs/base/common/marked/marked
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
*
as
uuid
from
'
vs/base/common/uuid
'
;
import
{
CodeEditor
}
from
'
vs/editor/browser/codeEditor
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
*
as
path
from
'
path
'
;
import
{
tmpdir
}
from
'
os
'
;
import
{
mkdirp
}
from
'
vs/base/node/extfs
'
;
import
{
IMode
}
from
'
vs/editor/common/modes
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
localize
}
from
'
vs/nls
'
;
...
...
@@ -116,15 +112,12 @@ export class WalkThroughPart extends BaseEditor {
this
.
contentDisposables
=
dispose
(
this
.
contentDisposables
);
this
.
content
.
innerHTML
=
''
;
const
folderName
=
path
.
join
(
tmpdir
(),
'
vscode-walk-through
'
,
uuid
.
generateUuid
());
const
folder
=
new
TPromise
<
string
>
((
c
,
e
)
=>
mkdirp
(
folderName
,
null
,
err
=>
err
?
e
(
err
)
:
c
(
folderName
)));
return
super
.
setInput
(
input
,
options
)
.
then
(()
=>
{
return
input
.
resolve
(
true
);
})
.
then
(
model
=>
{
const
content
=
model
.
textEditorModel
.
getLinesContent
().
join
(
'
\n
'
);
const
content
=
model
.
main
.
textEditorModel
.
getLinesContent
().
join
(
'
\n
'
);
if
(
strings
.
endsWith
(
input
.
getResource
().
path
,
'
.html
'
))
{
this
.
content
.
innerHTML
=
content
;
this
.
decorateContent
();
...
...
@@ -135,19 +128,10 @@ export class WalkThroughPart extends BaseEditor {
return
;
}
const
files
:
TPromise
<
any
>
[]
=
[];
const
codes
:
{
id
:
string
;
model
:
IModel
}[]
=
[];
let
i
=
0
;
const
renderer
=
new
marked
.
Renderer
();
renderer
.
code
=
(
code
,
lang
)
=>
{
const
id
=
`code-
${
uuid
.
generateUuid
()}
`
;
const
mode
=
this
.
getModeForLanguage
(
lang
);
const
resource
=
URI
.
file
(
path
.
join
(
folderName
,
`
${
id
}
.
${
lang
}
`
));
const
model
=
this
.
modelService
.
createModel
(
code
,
mode
,
resource
);
codes
.
push
({
id
,
model
});
// E.g., the TypeScript service needs files on disk.
files
.
push
(
folder
.
then
(()
=>
this
.
fileService
.
createFile
(
resource
,
code
)));
const
id
=
path
.
basename
(
model
.
snippets
[
i
++
].
textEditorModel
.
uri
.
fsPath
);
return
`<div id=
${
id
}
class="walkThroughEditorContainer" ></div>`
;
};
this
.
content
.
classList
.
add
(
'
walkThroughContent
'
);
// only for markdown files
...
...
@@ -155,56 +139,37 @@ export class WalkThroughPart extends BaseEditor {
this
.
content
.
innerHTML
=
marked
(
markdown
,
{
renderer
});
// TODO: also create jsconfig.json and tsconfig.json
return
TPromise
.
join
(
files
).
then
(()
=>
{
codes
.
forEach
(({
id
,
model
})
=>
{
const
div
=
this
.
content
.
querySelector
(
`#
${
id
}
`
)
as
HTMLElement
;
var
options
:
IEditorOptions
=
{
scrollBeyondLastLine
:
false
,
scrollbar
:
DefaultConfig
.
editor
.
scrollbar
,
overviewRulerLanes
:
3
,
fixedOverflowWidgets
:
true
,
lineNumbersMinChars
:
1
,
theme
:
this
.
themeService
.
getColorTheme
().
id
,
};
const
editor
=
this
.
instantiationService
.
createInstance
(
CodeEditor
,
div
,
options
);
editor
.
setModel
(
model
);
this
.
contentDisposables
.
push
(
editor
);
const
lineHeight
=
editor
.
getConfiguration
().
lineHeight
;
const
height
=
model
.
getLineCount
()
*
lineHeight
;
div
.
style
.
height
=
height
+
'
px
'
;
this
.
contentDisposables
.
push
(
this
.
themeService
.
onDidColorThemeChange
(
theme
=>
editor
.
updateOptions
({
theme
:
theme
.
id
})));
editor
.
layout
();
});
if
(
input
.
onReady
)
{
input
.
onReady
(
this
.
content
);
}
this
.
scrollbar
.
scanDomNode
();
model
.
snippets
.
forEach
(
snippet
=>
{
const
model
=
snippet
.
textEditorModel
;
const
id
=
path
.
basename
(
model
.
uri
.
fsPath
);
const
div
=
this
.
content
.
querySelector
(
`#
${
id
.
replace
(
/
\.
/g
,
'
\\
.
'
)}
`
)
as
HTMLElement
;
var
options
:
IEditorOptions
=
{
scrollBeyondLastLine
:
false
,
scrollbar
:
DefaultConfig
.
editor
.
scrollbar
,
overviewRulerLanes
:
3
,
fixedOverflowWidgets
:
true
,
lineNumbersMinChars
:
1
,
theme
:
this
.
themeService
.
getColorTheme
().
id
,
};
const
editor
=
this
.
instantiationService
.
createInstance
(
CodeEditor
,
div
,
options
);
editor
.
setModel
(
model
);
this
.
contentDisposables
.
push
(
editor
);
const
lineHeight
=
editor
.
getConfiguration
().
lineHeight
;
const
height
=
model
.
getLineCount
()
*
lineHeight
;
div
.
style
.
height
=
height
+
'
px
'
;
this
.
contentDisposables
.
push
(
this
.
themeService
.
onDidColorThemeChange
(
theme
=>
editor
.
updateOptions
({
theme
:
theme
.
id
})));
editor
.
layout
();
});
});
}
private
getModeForLanguage
(
lang
:
string
):
TPromise
<
IMode
>
{
return
new
TPromise
(
c
=>
{
const
that
=
this
;
function
tryGetMode
()
{
const
modeId
=
that
.
modeService
.
getModeIdForLanguageName
(
lang
);
const
mode
=
modeId
&&
that
.
modeService
.
getOrCreateMode
(
modeId
);
if
(
mode
)
{
c
(
mode
);
}
else
{
const
subscription
=
that
.
modeService
.
onDidAddModes
(()
=>
{
subscription
.
dispose
();
tryGetMode
();
});
if
(
input
.
onReady
)
{
input
.
onReady
(
this
.
content
);
}
}
tryGetMode
();
});
this
.
scrollbar
.
scanDomNode
();
});
}
private
expandMacros
(
input
:
string
)
{
...
...
src/vs/workbench/parts/walkThrough/node/walkThroughInput.ts
0 → 100644
浏览文件 @
c59da6a4
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
EditorInput
,
EditorModel
,
ITextEditorModel
}
from
'
vs/workbench/common/editor
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
IReference
}
from
'
vs/base/common/lifecycle
'
;
import
{
telemetryURIDescriptor
}
from
'
vs/platform/telemetry/common/telemetryUtils
'
;
import
{
ITextModelResolverService
}
from
'
vs/editor/common/services/resolverService
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
*
as
uuid
from
'
vs/base/common/uuid
'
;
import
*
as
path
from
'
path
'
;
import
{
tmpdir
}
from
'
os
'
;
import
{
mkdirp
}
from
'
vs/base/node/extfs
'
;
import
{
marked
}
from
'
vs/base/common/marked/marked
'
;
export
class
WalkThroughModel
extends
EditorModel
{
constructor
(
private
mainRef
:
IReference
<
ITextEditorModel
>
,
private
snippetRefs
:
IReference
<
ITextEditorModel
>
[]
)
{
super
();
}
get
main
()
{
return
this
.
mainRef
.
object
;
}
get
snippets
()
{
return
this
.
snippetRefs
.
map
(
snippet
=>
snippet
.
object
);
}
dispose
()
{
this
.
snippetRefs
.
forEach
(
ref
=>
ref
.
dispose
());
this
.
mainRef
.
dispose
();
super
.
dispose
();
}
}
export
class
WalkThroughInput
extends
EditorInput
{
static
ID
:
string
=
'
workbench.editors.walkThroughInput
'
;
private
promise
:
TPromise
<
WalkThroughModel
>
;
private
resource
:
URI
;
private
name
:
string
;
private
description
:
string
;
constructor
(
name
:
string
,
description
:
string
,
resource
:
URI
,
public
readonly
onReady
:
(
container
:
HTMLElement
)
=>
void
,
@
IFileService
private
fileService
:
IFileService
,
@
ITextModelResolverService
private
textModelResolverService
:
ITextModelResolverService
)
{
super
();
this
.
name
=
name
;
this
.
description
=
description
;
this
.
resource
=
resource
;
}
getResource
():
URI
{
return
this
.
resource
;
}
getTypeId
():
string
{
return
WalkThroughInput
.
ID
;
}
getName
():
string
{
return
this
.
name
;
}
getDescription
():
string
{
return
this
.
description
;
}
getTelemetryDescriptor
():
{
[
key
:
string
]:
any
;
}
{
const
descriptor
=
super
.
getTelemetryDescriptor
();
descriptor
[
'
resource
'
]
=
telemetryURIDescriptor
(
this
.
resource
);
return
descriptor
;
}
resolve
(
refresh
?:
boolean
):
TPromise
<
WalkThroughModel
>
{
if
(
!
this
.
promise
)
{
this
.
promise
=
this
.
textModelResolverService
.
createModelReference
(
this
.
resource
)
.
then
(
ref
=>
{
if
(
strings
.
endsWith
(
this
.
getResource
().
path
,
'
.html
'
))
{
return
new
WalkThroughModel
(
ref
,
[]);
}
const
folderName
=
path
.
join
(
tmpdir
(),
'
vscode-walk-through
'
,
uuid
.
generateUuid
());
const
folder
=
new
TPromise
<
string
>
((
c
,
e
)
=>
mkdirp
(
folderName
,
null
,
err
=>
err
?
e
(
err
)
:
c
(
folderName
)));
const
snippets
:
TPromise
<
IReference
<
ITextEditorModel
>>
[]
=
[];
const
renderer
=
new
marked
.
Renderer
();
renderer
.
code
=
(
code
,
lang
)
=>
{
const
id
=
`code-
${
uuid
.
generateUuid
()}
`
;
const
resource
=
URI
.
file
(
path
.
join
(
folderName
,
`
${
id
}
.
${
lang
}
`
));
// E.g., the TypeScript service needs files on disk.
snippets
.
push
(
folder
.
then
(()
=>
this
.
fileService
.
createFile
(
resource
,
code
))
.
then
(()
=>
this
.
textModelResolverService
.
createModelReference
(
resource
)));
return
''
;
};
const
markdown
=
ref
.
object
.
textEditorModel
.
getLinesContent
().
join
(
'
\n
'
);
marked
(
markdown
,
{
renderer
});
return
TPromise
.
join
(
snippets
)
.
then
(
refs
=>
new
WalkThroughModel
(
ref
,
refs
));
});
}
return
this
.
promise
;
// TODO: replicate above?
// return this.promise.then(ref => {
// const model = ref.object;
// if (!(model instanceof ResourceEditorModel)) {
// ref.dispose();
// this.promise = null;
// return TPromise.wrapError(`Unexpected model for ResourceInput: ${this.resource}`); // TODO@Ben eventually also files should be supported, but we guard due to the dangerous dispose of the model in dispose()
// }
// // TODO@Joao this should never happen
// model.onDispose(() => this.dispose());
// return model;
// });
}
matches
(
otherInput
:
any
):
boolean
{
if
(
super
.
matches
(
otherInput
)
===
true
)
{
return
true
;
}
if
(
otherInput
instanceof
WalkThroughInput
)
{
let
otherResourceEditorInput
=
<
WalkThroughInput
>
otherInput
;
// Compare by properties
return
otherResourceEditorInput
.
resource
.
toString
()
===
this
.
resource
.
toString
();
}
return
false
;
}
dispose
():
void
{
if
(
this
.
promise
)
{
this
.
promise
.
then
(
model
=>
model
.
dispose
());
this
.
promise
=
null
;
}
super
.
dispose
();
}
}
src/vs/workbench/parts/welcomePage/electron-browser/welcomePage.ts
浏览文件 @
c59da6a4
...
...
@@ -7,7 +7,7 @@
import
'
vs/css!./welcomePage
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
*
as
path
from
'
path
'
;
import
{
WalkThroughInput
}
from
'
vs/workbench/parts/walkThrough/
common
/walkThroughInput
'
;
import
{
WalkThroughInput
}
from
'
vs/workbench/parts/walkThrough/
node
/walkThroughInput
'
;
import
{
IWorkbenchContribution
}
from
'
vs/workbench/common/contributions
'
;
import
{
IPartService
}
from
'
vs/workbench/services/part/common/partService
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录