Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
74245ac1
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,发现更多精彩内容 >>
提交
74245ac1
编写于
3月 27, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes #21656: Toggle Wordwrap should toggle back to configured value
上级
60f1c78b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
85 addition
and
15 deletion
+85
-15
src/vs/editor/common/services/abstractCodeEditorService.ts
src/vs/editor/common/services/abstractCodeEditorService.ts
+50
-1
src/vs/editor/common/services/codeEditorService.ts
src/vs/editor/common/services/codeEditorService.ts
+4
-1
src/vs/workbench/parts/codeEditor/electron-browser/toggleWordWrap.ts
...bench/parts/codeEditor/electron-browser/toggleWordWrap.ts
+31
-13
未找到文件。
src/vs/editor/common/services/abstractCodeEditorService.ts
浏览文件 @
74245ac1
...
...
@@ -5,7 +5,7 @@
'
use strict
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
ICommonCodeEditor
,
ICommonDiffEditor
,
IDecorationRenderOptions
,
IModelDecorationOptions
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ICommonCodeEditor
,
ICommonDiffEditor
,
IDecorationRenderOptions
,
IModelDecorationOptions
,
IModel
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/common/services/codeEditorService
'
;
export
abstract
class
AbstractCodeEditorService
implements
ICodeEditorService
{
...
...
@@ -106,4 +106,53 @@ export abstract class AbstractCodeEditorService implements ICodeEditorService {
abstract
registerDecorationType
(
key
:
string
,
options
:
IDecorationRenderOptions
,
parentTypeKey
?:
string
):
void
;
abstract
removeDecorationType
(
key
:
string
):
void
;
abstract
resolveDecorationOptions
(
decorationTypeKey
:
string
,
writable
:
boolean
):
IModelDecorationOptions
;
private
_transientWatchers
:
{
[
uri
:
string
]:
ModelTransientSettingWatcher
;
}
=
{};
public
setTransientModelProperty
(
model
:
IModel
,
key
:
string
,
value
:
any
):
void
{
const
uri
=
model
.
uri
.
toString
();
let
w
:
ModelTransientSettingWatcher
;
if
(
this
.
_transientWatchers
.
hasOwnProperty
(
uri
))
{
w
=
this
.
_transientWatchers
[
uri
];
}
else
{
w
=
new
ModelTransientSettingWatcher
(
uri
,
model
,
this
);
this
.
_transientWatchers
[
uri
]
=
w
;
}
w
.
set
(
key
,
value
);
}
public
getTransientModelProperty
(
model
:
IModel
,
key
:
string
):
any
{
const
uri
=
model
.
uri
.
toString
();
if
(
!
this
.
_transientWatchers
.
hasOwnProperty
(
uri
))
{
return
undefined
;
}
return
this
.
_transientWatchers
[
uri
].
get
(
key
);
}
_removeWatcher
(
w
:
ModelTransientSettingWatcher
):
void
{
delete
this
.
_transientWatchers
[
w
.
uri
];
}
}
export
class
ModelTransientSettingWatcher
{
public
readonly
uri
:
string
;
private
readonly
_values
:
{
[
key
:
string
]:
any
;
};
constructor
(
uri
:
string
,
model
:
IModel
,
owner
:
AbstractCodeEditorService
)
{
this
.
uri
=
uri
;
this
.
_values
=
{};
model
.
onWillDispose
(()
=>
owner
.
_removeWatcher
(
this
));
}
public
set
(
key
:
string
,
value
:
any
):
void
{
this
.
_values
[
key
]
=
value
;
}
public
get
(
key
:
string
):
any
{
return
this
.
_values
[
key
];
}
}
src/vs/editor/common/services/codeEditorService.ts
浏览文件 @
74245ac1
...
...
@@ -6,7 +6,7 @@
import
Event
from
'
vs/base/common/event
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ICommonCodeEditor
,
ICommonDiffEditor
,
isCommonCodeEditor
,
isCommonDiffEditor
,
IDecorationRenderOptions
,
IModelDecorationOptions
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ICommonCodeEditor
,
ICommonDiffEditor
,
isCommonCodeEditor
,
isCommonDiffEditor
,
IDecorationRenderOptions
,
IModelDecorationOptions
,
IModel
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IEditor
}
from
'
vs/platform/editor/common/editor
'
;
export
var
ICodeEditorService
=
createDecorator
<
ICodeEditorService
>
(
'
codeEditorService
'
);
...
...
@@ -38,6 +38,9 @@ export interface ICodeEditorService {
registerDecorationType
(
key
:
string
,
options
:
IDecorationRenderOptions
,
parentTypeKey
?:
string
):
void
;
removeDecorationType
(
key
:
string
):
void
;
resolveDecorationOptions
(
typeKey
:
string
,
writable
:
boolean
):
IModelDecorationOptions
;
setTransientModelProperty
(
model
:
IModel
,
key
:
string
,
value
:
any
):
void
;
getTransientModelProperty
(
model
:
IModel
,
key
:
string
):
any
;
}
/**
...
...
src/vs/workbench/parts/codeEditor/electron-browser/toggleWordWrap.ts
浏览文件 @
74245ac1
...
...
@@ -8,6 +8,9 @@ import * as nls from 'vs/nls';
import
{
KeyCode
,
KeyMod
}
from
'
vs/base/common/keyCodes
'
;
import
{
ICommonCodeEditor
}
from
'
vs/editor/common/editorCommon
'
;
import
{
editorAction
,
ServicesAccessor
,
EditorAction
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/common/services/codeEditorService
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
DefaultConfig
}
from
'
vs/editor/common/config/defaultConfig
'
;
@
editorAction
class
ToggleWordWrapAction
extends
EditorAction
{
...
...
@@ -26,20 +29,35 @@ class ToggleWordWrapAction extends EditorAction {
}
public
run
(
accessor
:
ServicesAccessor
,
editor
:
ICommonCodeEditor
):
void
{
let
wrappingInfo
=
editor
.
getConfiguration
().
wrappingInfo
;
let
newWordWrap
:
'
on
'
|
'
off
'
;
let
newWordWrapMinified
:
boolean
;
if
(
!
wrappingInfo
.
isViewportWrapping
)
{
newWordWrap
=
'
on
'
;
newWordWrapMinified
=
true
;
const
codeEditorService
=
accessor
.
get
(
ICodeEditorService
);
const
configurationService
=
accessor
.
get
(
IConfigurationService
);
const
model
=
editor
.
getModel
();
const
_configuredWordWrap
=
configurationService
.
lookup
<
'
on
'
|
'
off
'
|
'
wordWrapColumn
'
|
'
bounded
'
>
(
'
editor.wordWrap
'
,
model
.
getLanguageIdentifier
().
language
);
const
_configuredWordWrapMinified
=
configurationService
.
lookup
<
boolean
>
(
'
editor.wordWrapMinified
'
,
model
.
getLanguageIdentifier
().
language
);
const
configuredWordWrap
=
_configuredWordWrap
.
value
;
const
configuredWordWrapMinified
=
(
typeof
_configuredWordWrapMinified
.
value
===
'
undefined
'
?
DefaultConfig
.
editor
.
wordWrapMinified
:
_configuredWordWrapMinified
.
value
);
const
alreadyToggled
=
codeEditorService
.
getTransientModelProperty
(
model
,
'
toggleWordWrap
'
);
if
(
!
alreadyToggled
)
{
codeEditorService
.
setTransientModelProperty
(
model
,
'
toggleWordWrap
'
,
true
);
if
(
configuredWordWrap
!==
'
off
'
)
{
editor
.
updateOptions
({
wordWrap
:
'
off
'
,
wordWrapMinified
:
false
});
}
else
{
editor
.
updateOptions
({
wordWrap
:
'
on
'
});
}
}
else
{
newWordWrap
=
'
off
'
;
newWordWrapMinified
=
false
;
codeEditorService
.
setTransientModelProperty
(
model
,
'
toggleWordWrap
'
,
false
);
editor
.
updateOptions
({
wordWrap
:
configuredWordWrap
,
wordWrapMinified
:
configuredWordWrapMinified
});
}
editor
.
updateOptions
({
wordWrap
:
newWordWrap
,
wordWrapMinified
:
newWordWrapMinified
});
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录