Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
75ffa8be
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,发现更多精彩内容 >>
提交
75ffa8be
编写于
9月 02, 2019
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
- Add a typed way to read options
- Move more options to the new format
上级
2a720880
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
44 addition
and
40 deletion
+44
-40
src/vs/editor/browser/controller/mouseHandler.ts
src/vs/editor/browser/controller/mouseHandler.ts
+2
-1
src/vs/editor/browser/editorBrowser.ts
src/vs/editor/browser/editorBrowser.ts
+2
-0
src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts
src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts
+1
-1
src/vs/editor/browser/widget/codeEditorWidget.ts
src/vs/editor/browser/widget/codeEditorWidget.ts
+4
-0
src/vs/editor/common/config/commonEditorConfig.ts
src/vs/editor/common/config/commonEditorConfig.ts
+6
-2
src/vs/editor/common/config/editorOptions.ts
src/vs/editor/common/config/editorOptions.ts
+10
-21
src/vs/editor/common/editorCommon.ts
src/vs/editor/common/editorCommon.ts
+2
-1
src/vs/editor/common/standalone/standaloneEnums.ts
src/vs/editor/common/standalone/standaloneEnums.ts
+3
-1
src/vs/monaco.d.ts
src/vs/monaco.d.ts
+10
-9
src/vs/workbench/contrib/codeEditor/browser/selectionClipboard.ts
...orkbench/contrib/codeEditor/browser/selectionClipboard.ts
+4
-4
未找到文件。
src/vs/editor/browser/controller/mouseHandler.ts
浏览文件 @
75ffa8be
...
...
@@ -21,6 +21,7 @@ import { HorizontalRange } from 'vs/editor/common/view/renderingContext';
import
{
ViewContext
}
from
'
vs/editor/common/view/viewContext
'
;
import
*
as
viewEvents
from
'
vs/editor/common/view/viewEvents
'
;
import
{
ViewEventHandler
}
from
'
vs/editor/common/viewModel/viewEventHandler
'
;
import
{
EditorOptionId
,
EditorOption
}
from
'
vs/editor/common/config/editorOptions
'
;
/**
* Merges mouse events when mouse move events are throttled
...
...
@@ -216,7 +217,7 @@ export class MouseHandler extends ViewEventHandler {
const
targetIsContent
=
(
t
.
type
===
editorBrowser
.
MouseTargetType
.
CONTENT_TEXT
||
t
.
type
===
editorBrowser
.
MouseTargetType
.
CONTENT_EMPTY
);
const
targetIsGutter
=
(
t
.
type
===
editorBrowser
.
MouseTargetType
.
GUTTER_GLYPH_MARGIN
||
t
.
type
===
editorBrowser
.
MouseTargetType
.
GUTTER_LINE_NUMBERS
||
t
.
type
===
editorBrowser
.
MouseTargetType
.
GUTTER_LINE_DECORATIONS
);
const
targetIsLineNumbers
=
(
t
.
type
===
editorBrowser
.
MouseTargetType
.
GUTTER_LINE_NUMBERS
);
const
selectOnLineNumbers
=
this
.
_context
.
configuration
.
editor
.
viewInfo
.
selectOnLineNumbers
;
const
selectOnLineNumbers
=
this
.
_context
.
configuration
.
getOption
<
typeof
EditorOption
.
selectOnLineNumbers
>
(
EditorOptionId
.
selectOnLineNumbers
)
;
const
targetIsViewZone
=
(
t
.
type
===
editorBrowser
.
MouseTargetType
.
CONTENT_VIEW_ZONE
||
t
.
type
===
editorBrowser
.
MouseTargetType
.
GUTTER_VIEW_ZONE
);
const
targetIsWidget
=
(
t
.
type
===
editorBrowser
.
MouseTargetType
.
CONTENT_WIDGET
);
...
...
src/vs/editor/browser/editorBrowser.ts
浏览文件 @
75ffa8be
...
...
@@ -536,6 +536,8 @@ export interface ICodeEditor extends editorCommon.IEditor {
*/
getConfiguration
():
editorOptions
.
InternalEditorOptions
;
getOption
<
T
extends
editorOptions
.
IEditorOption
<
any
,
any
,
any
>>
(
id
:
editorOptions
.
EditorOptionId
):
editorOptions
.
ComputedEditorOptionValue
<
T
>
;
/**
* Returns the 'raw' editor's configuration (without any validation or defaults).
* @internal
...
...
src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts
浏览文件 @
75ffa8be
...
...
@@ -45,7 +45,7 @@ export class LineNumbersOverlay extends DynamicViewOverlay {
this
.
_lineHeight
=
config
.
lineHeight
;
this
.
_renderLineNumbers
=
config
.
viewInfo
.
renderLineNumbers
;
this
.
_renderCustomLineNumbers
=
config
.
viewInfo
.
renderCustomLineNumbers
;
this
.
_renderFinalNewline
=
this
.
_context
.
configuration
.
options
.
get
(
EditorOptionId
.
RenderFinalNewline
,
EditorOption
.
R
enderFinalNewline
);
this
.
_renderFinalNewline
=
this
.
_context
.
configuration
.
getOption
<
typeof
EditorOption
.
renderFinalNewline
>
(
EditorOptionId
.
r
enderFinalNewline
);
this
.
_lineNumbersLeft
=
config
.
layoutInfo
.
lineNumbersLeft
;
this
.
_lineNumbersWidth
=
config
.
layoutInfo
.
lineNumbersWidth
;
}
...
...
src/vs/editor/browser/widget/codeEditorWidget.ts
浏览文件 @
75ffa8be
...
...
@@ -370,6 +370,10 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
return
this
.
_configuration
.
editor
;
}
public
getOption
<
T
extends
editorOptions
.
IEditorOption
<
any
,
any
,
any
>>
(
id
:
editorOptions
.
EditorOptionId
):
editorOptions
.
ComputedEditorOptionValue
<
T
>
{
return
this
.
_configuration
.
getOption
<
T
>
(
id
);
}
public
getRawConfiguration
():
editorOptions
.
IEditorOptions
{
return
this
.
_configuration
.
getRawOptions
();
}
...
...
src/vs/editor/common/config/commonEditorConfig.ts
浏览文件 @
75ffa8be
...
...
@@ -156,6 +156,10 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed
this
.
_register
(
TabFocus
.
onDidChangeTabFocus
(
_
=>
this
.
_recomputeOptions
()));
}
public
getOption
<
T
extends
editorOptions
.
IEditorOption
<
any
,
any
,
any
>>
(
id
:
editorOptions
.
EditorOptionId
):
editorOptions
.
ComputedEditorOptionValue
<
T
>
{
return
this
.
options
.
_read
(
id
);
}
public
observeReferenceElement
(
dimension
?:
editorCommon
.
IDimension
):
void
{
}
...
...
@@ -345,7 +349,7 @@ const editorConfiguration: IConfigurationNode = {
},
'
editor.renderFinalNewline
'
:
{
'
type
'
:
'
boolean
'
,
'
default
'
:
editorOptions
.
EditorOption
.
R
enderFinalNewline
.
defaultValue
,
'
default
'
:
editorOptions
.
EditorOption
.
r
enderFinalNewline
.
defaultValue
,
'
description
'
:
nls
.
localize
(
'
renderFinalNewline
'
,
"
Render last line number when the file ends with a newline.
"
)
},
'
editor.rulers
'
:
{
...
...
@@ -1137,7 +1141,7 @@ const editorConfiguration: IConfigurationNode = {
},
'
editor.selectionClipboard
'
:
{
'
type
'
:
'
boolean
'
,
'
default
'
:
EDITOR_DEFAULTS
.
contribInfo
.
selectionClipboard
,
'
default
'
:
editorOptions
.
EditorOption
.
selectionClipboard
.
defaultValue
,
'
description
'
:
nls
.
localize
(
'
selectionClipboard
'
,
"
Controls whether the Linux primary clipboard should be supported.
"
),
'
included
'
:
platform
.
isLinux
},
...
...
src/vs/editor/common/config/editorOptions.ts
浏览文件 @
75ffa8be
...
...
@@ -997,7 +997,6 @@ export interface InternalEditorViewOptions {
readonly
renderLineNumbers
:
RenderLineNumbersType
;
readonly
renderCustomLineNumbers
:
((
lineNumber
:
number
)
=>
string
)
|
null
;
readonly
cursorSurroundingLines
:
number
;
readonly
selectOnLineNumbers
:
boolean
;
readonly
glyphMargin
:
boolean
;
readonly
revealHorizontalRightPadding
:
number
;
readonly
roundedSelection
:
boolean
;
...
...
@@ -1025,7 +1024,6 @@ export interface InternalEditorViewOptions {
}
export
interface
EditorContribOptions
{
readonly
selectionClipboard
:
boolean
;
readonly
hover
:
InternalEditorHoverOptions
;
readonly
links
:
boolean
;
readonly
contextmenu
:
boolean
;
...
...
@@ -1317,7 +1315,6 @@ export class InternalEditorOptions {
&&
a
.
renderLineNumbers
===
b
.
renderLineNumbers
&&
a
.
renderCustomLineNumbers
===
b
.
renderCustomLineNumbers
&&
a
.
cursorSurroundingLines
===
b
.
cursorSurroundingLines
&&
a
.
selectOnLineNumbers
===
b
.
selectOnLineNumbers
&&
a
.
glyphMargin
===
b
.
glyphMargin
&&
a
.
revealHorizontalRightPadding
===
b
.
revealHorizontalRightPadding
&&
a
.
roundedSelection
===
b
.
roundedSelection
...
...
@@ -1464,8 +1461,7 @@ export class InternalEditorOptions {
*/
private
static
_equalsContribOptions
(
a
:
EditorContribOptions
,
b
:
EditorContribOptions
):
boolean
{
return
(
a
.
selectionClipboard
===
b
.
selectionClipboard
&&
this
.
_equalsHoverOptions
(
a
.
hover
,
b
.
hover
)
this
.
_equalsHoverOptions
(
a
.
hover
,
b
.
hover
)
&&
a
.
links
===
b
.
links
&&
a
.
contextmenu
===
b
.
contextmenu
&&
InternalEditorOptions
.
_equalsQuickSuggestions
(
a
.
quickSuggestions
,
b
.
quickSuggestions
)
...
...
@@ -2081,7 +2077,6 @@ export class EditorOptionsValidator {
cursorSurroundingLines
:
_clampedInt
(
opts
.
cursorSurroundingLines
,
defaults
.
cursorWidth
,
0
,
Number
.
MAX_VALUE
),
renderLineNumbers
:
renderLineNumbers
,
renderCustomLineNumbers
:
renderCustomLineNumbers
,
selectOnLineNumbers
:
_boolean
(
opts
.
selectOnLineNumbers
,
defaults
.
selectOnLineNumbers
),
glyphMargin
:
_boolean
(
opts
.
glyphMargin
,
defaults
.
glyphMargin
),
revealHorizontalRightPadding
:
_clampedInt
(
opts
.
revealHorizontalRightPadding
,
defaults
.
revealHorizontalRightPadding
,
0
,
1000
),
roundedSelection
:
_boolean
(
opts
.
roundedSelection
,
defaults
.
roundedSelection
),
...
...
@@ -2122,7 +2117,6 @@ export class EditorOptionsValidator {
}
const
find
=
this
.
_sanitizeFindOpts
(
opts
.
find
,
defaults
.
find
);
return
{
selectionClipboard
:
_boolean
(
opts
.
selectionClipboard
,
defaults
.
selectionClipboard
),
hover
:
this
.
_sanitizeHoverOpts
(
opts
.
hover
,
defaults
.
hover
),
links
:
_boolean
(
opts
.
links
,
defaults
.
links
),
contextmenu
:
_boolean
(
opts
.
contextmenu
,
defaults
.
contextmenu
),
...
...
@@ -2202,7 +2196,6 @@ export class InternalEditorOptionsFactory {
renderLineNumbers
:
opts
.
viewInfo
.
renderLineNumbers
,
renderCustomLineNumbers
:
opts
.
viewInfo
.
renderCustomLineNumbers
,
cursorSurroundingLines
:
opts
.
viewInfo
.
cursorSurroundingLines
,
selectOnLineNumbers
:
opts
.
viewInfo
.
selectOnLineNumbers
,
glyphMargin
:
opts
.
viewInfo
.
glyphMargin
,
revealHorizontalRightPadding
:
opts
.
viewInfo
.
revealHorizontalRightPadding
,
roundedSelection
:
opts
.
viewInfo
.
roundedSelection
,
...
...
@@ -2236,7 +2229,6 @@ export class InternalEditorOptionsFactory {
},
contribInfo
:
{
selectionClipboard
:
opts
.
contribInfo
.
selectionClipboard
,
hover
:
opts
.
contribInfo
.
hover
,
links
:
opts
.
contribInfo
.
links
,
contextmenu
:
opts
.
contribInfo
.
contextmenu
,
...
...
@@ -2668,7 +2660,6 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
renderLineNumbers
:
RenderLineNumbersType
.
On
,
renderCustomLineNumbers
:
null
,
cursorSurroundingLines
:
0
,
selectOnLineNumbers
:
true
,
glyphMargin
:
true
,
revealHorizontalRightPadding
:
30
,
roundedSelection
:
true
,
...
...
@@ -2716,7 +2707,6 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
},
contribInfo
:
{
selectionClipboard
:
true
,
hover
:
{
enabled
:
true
,
delay
:
300
,
...
...
@@ -2803,10 +2793,6 @@ export class ValidatedEditorOptions {
}
}
export
interface
IComputedEditorOptions
{
get
<
T1
,
T2
,
T3
>
(
id
:
EditorOptionId
,
option
:
IEditorOption
<
T1
,
T2
,
T3
>
):
T3
;
}
/**
* @internal
*/
...
...
@@ -2815,9 +2801,6 @@ export class ComputedEditorOptions {
public
_read
<
T
>
(
id
:
EditorOptionId
):
T
{
return
this
.
_values
[
id
];
}
public
get
<
T1
,
T2
,
T3
>
(
id
:
EditorOptionId
,
option
:
IEditorOption
<
T1
,
T2
,
T3
>
):
T3
{
return
this
.
_values
[
id
];
}
public
_write
<
T
>
(
id
:
EditorOptionId
,
value
:
T
):
void
{
this
.
_values
[
id
]
=
value
;
}
...
...
@@ -2836,7 +2819,7 @@ export class ChangedEditorOptions {
}
}
interface
IEditorOption
<
T1
,
T2
=
T1
,
T3
=
T2
>
{
export
interface
IEditorOption
<
T1
,
T2
=
T1
,
T3
=
T2
>
{
readonly
id
:
EditorOptionId
;
readonly
name
:
string
;
readonly
defaultValue
:
T1
;
...
...
@@ -2890,9 +2873,15 @@ function registerEditorOption<T1, T2, T3>(option: IEditorOption<T1, T2, T3>): IE
}
export
const
enum
EditorOptionId
{
RenderFinalNewline
,
renderFinalNewline
,
selectionClipboard
,
selectOnLineNumbers
,
}
export
const
EditorOption
=
{
RenderFinalNewline
:
registerEditorOption
(
new
BooleanEditorOption
(
EditorOptionId
.
RenderFinalNewline
,
'
renderFinalNewline
'
,
true
))
renderFinalNewline
:
registerEditorOption
(
new
BooleanEditorOption
(
EditorOptionId
.
renderFinalNewline
,
'
renderFinalNewline
'
,
true
)),
selectionClipboard
:
registerEditorOption
(
new
BooleanEditorOption
(
EditorOptionId
.
selectionClipboard
,
'
selectionClipboard
'
,
true
)),
selectOnLineNumbers
:
registerEditorOption
(
new
BooleanEditorOption
(
EditorOptionId
.
selectOnLineNumbers
,
'
selectOnLineNumbers
'
,
true
)),
};
export
type
ComputedEditorOptionValue
<
T
extends
IEditorOption
<
any
,
any
,
any
>>
=
T
extends
IEditorOption
<
any
,
any
,
infer
R
>
?
R
:
never
;
src/vs/editor/common/editorCommon.ts
浏览文件 @
75ffa8be
...
...
@@ -152,7 +152,8 @@ export interface IConfiguration extends IDisposable {
onDidChange
(
listener
:
(
e
:
editorOptions
.
IConfigurationChangedEvent
)
=>
void
):
IDisposable
;
readonly
editor
:
editorOptions
.
InternalEditorOptions
;
readonly
options
:
editorOptions
.
IComputedEditorOptions
;
getOption
<
T
extends
editorOptions
.
IEditorOption
<
any
,
any
,
any
>>
(
id
:
editorOptions
.
EditorOptionId
):
editorOptions
.
ComputedEditorOptionValue
<
T
>
;
setMaxLineNumber
(
maxLineNumber
:
number
):
void
;
updateOptions
(
newOptions
:
editorOptions
.
IEditorOptions
):
void
;
...
...
src/vs/editor/common/standalone/standaloneEnums.ts
浏览文件 @
75ffa8be
...
...
@@ -431,7 +431,9 @@ export enum RenderLineNumbersType {
}
export
enum
EditorOptionId
{
RenderFinalNewline
=
0
renderFinalNewline
=
0
,
selectionClipboard
=
1
,
selectOnLineNumbers
=
2
}
/**
...
...
src/vs/monaco.d.ts
浏览文件 @
75ffa8be
...
...
@@ -3312,7 +3312,6 @@ declare namespace monaco.editor {
readonly
renderLineNumbers
:
RenderLineNumbersType
;
readonly
renderCustomLineNumbers
:
((
lineNumber
:
number
)
=>
string
)
|
null
;
readonly
cursorSurroundingLines
:
number
;
readonly
selectOnLineNumbers
:
boolean
;
readonly
glyphMargin
:
boolean
;
readonly
revealHorizontalRightPadding
:
number
;
readonly
roundedSelection
:
boolean
;
...
...
@@ -3340,7 +3339,6 @@ declare namespace monaco.editor {
}
export
interface
EditorContribOptions
{
readonly
selectionClipboard
:
boolean
;
readonly
hover
:
InternalEditorHoverOptions
;
readonly
links
:
boolean
;
readonly
contextmenu
:
boolean
;
...
...
@@ -3555,11 +3553,7 @@ declare namespace monaco.editor {
[
key
:
string
]:
any
;
}
export
interface
IComputedEditorOptions
{
get
<
T1
,
T2
,
T3
>
(
id
:
EditorOptionId
,
option
:
IEditorOption
<
T1
,
T2
,
T3
>
):
T3
;
}
interface
IEditorOption
<
T1
,
T2
=
T1
,
T3
=
T2
>
{
export
interface
IEditorOption
<
T1
,
T2
=
T1
,
T3
=
T2
>
{
readonly
id
:
EditorOptionId
;
readonly
name
:
string
;
readonly
defaultValue
:
T1
;
...
...
@@ -3571,13 +3565,19 @@ declare namespace monaco.editor {
}
export
enum
EditorOptionId
{
RenderFinalNewline
=
0
renderFinalNewline
=
0
,
selectionClipboard
=
1
,
selectOnLineNumbers
=
2
}
export
const
EditorOption
:
{
RenderFinalNewline
:
IEditorOption
<
boolean
,
boolean
,
boolean
>
;
renderFinalNewline
:
IEditorOption
<
boolean
,
boolean
,
boolean
>
;
selectionClipboard
:
IEditorOption
<
boolean
,
boolean
,
boolean
>
;
selectOnLineNumbers
:
IEditorOption
<
boolean
,
boolean
,
boolean
>
;
};
export
type
ComputedEditorOptionValue
<
T
extends
IEditorOption
<
any
,
any
,
any
>>
=
T
extends
IEditorOption
<
any
,
any
,
infer
R
>
?
R
:
never
;
/**
* A view zone is a full horizontal rectangle that 'pushes' text down.
* The editor reserves space for view zones when rendering.
...
...
@@ -4027,6 +4027,7 @@ declare namespace monaco.editor {
* Returns the current editor's configuration
*/
getConfiguration
():
InternalEditorOptions
;
getOption
<
T
extends
IEditorOption
<
any
,
any
,
any
>>
(
id
:
EditorOptionId
):
ComputedEditorOptionValue
<
T
>
;
/**
* Get value of the current model attached to this editor.
* @see `ITextModel.getValue`
...
...
src/vs/workbench/contrib/codeEditor/browser/selectionClipboard.ts
浏览文件 @
75ffa8be
...
...
@@ -9,7 +9,7 @@ import * as process from 'vs/base/common/process';
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
{
ICodeEditor
,
IEditorMouseEvent
,
MouseTargetType
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
registerEditorContribution
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
IConfigurationChangedEvent
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
IConfigurationChangedEvent
,
EditorOption
,
EditorOptionId
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
ICursorSelectionChangedEvent
}
from
'
vs/editor/common/controller/cursorEvents
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
IEditorContribution
}
from
'
vs/editor/common/editorCommon
'
;
...
...
@@ -24,11 +24,11 @@ export class SelectionClipboard extends Disposable implements IEditorContributio
super
();
if
(
platform
.
isLinux
)
{
let
isEnabled
=
editor
.
get
Configuration
().
contribInfo
.
selectionClipboard
;
let
isEnabled
=
editor
.
get
Option
<
typeof
EditorOption
.
selectionClipboard
>
(
EditorOptionId
.
selectionClipboard
)
;
this
.
_register
(
editor
.
onDidChangeConfiguration
((
e
:
IConfigurationChangedEvent
)
=>
{
if
(
e
.
contribInfo
)
{
isEnabled
=
editor
.
get
Configuration
().
contribInfo
.
selectionClipboard
;
if
(
e
.
hasChanged
(
EditorOptionId
.
selectionClipboard
)
)
{
isEnabled
=
editor
.
get
Option
<
typeof
EditorOption
.
selectionClipboard
>
(
EditorOptionId
.
selectionClipboard
)
;
}
}));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录