Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
eb4d355a
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,发现更多精彩内容 >>
提交
eb4d355a
编写于
9月 12, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adopt CharacterClassifier in oneCursor
上级
cd410cb6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
28 addition
and
32 deletion
+28
-32
src/vs/editor/common/controller/oneCursor.ts
src/vs/editor/common/controller/oneCursor.ts
+28
-32
未找到文件。
src/vs/editor/common/controller/oneCursor.ts
浏览文件 @
eb4d355a
...
...
@@ -17,6 +17,7 @@ import * as editorCommon from 'vs/editor/common/editorCommon';
import
{
IElectricAction
,
IndentAction
}
from
'
vs/editor/common/modes
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
CharCode
}
from
'
vs/base/common/charCode
'
;
import
{
CharacterClassifier
}
from
'
vs/editor/common/core/characterClassifier
'
;
export
interface
IPostOperationRunnable
{
(
ctx
:
IOneCursorOperationContext
):
void
;
...
...
@@ -2272,7 +2273,7 @@ class CursorHelper {
let
wordType
=
W_NONE
;
for
(
let
chIndex
=
position
.
column
-
2
;
chIndex
>=
0
;
chIndex
--
)
{
let
chCode
=
lineContent
.
charCodeAt
(
chIndex
);
let
chClass
:
CharacterClass
=
(
wordSeparators
[
chCode
]
||
CharacterClass
.
Regular
);
let
chClass
=
wordSeparators
.
get
(
chCode
);
if
(
chClass
===
CH_REGULAR
)
{
if
(
wordType
===
W_SEPARATOR
)
{
...
...
@@ -2298,11 +2299,11 @@ class CursorHelper {
return
null
;
}
private
_findEndOfWord
(
lineContent
:
string
,
wordSeparators
:
CharacterClass
[]
,
wordType
:
WordType
,
startIndex
:
number
):
number
{
private
_findEndOfWord
(
lineContent
:
string
,
wordSeparators
:
WordCharacterClassifier
,
wordType
:
WordType
,
startIndex
:
number
):
number
{
let
len
=
lineContent
.
length
;
for
(
let
chIndex
=
startIndex
;
chIndex
<
len
;
chIndex
++
)
{
let
chCode
=
lineContent
.
charCodeAt
(
chIndex
);
let
chClass
:
CharacterClass
=
(
wordSeparators
[
chCode
]
||
CharacterClass
.
Regular
);
let
chClass
=
wordSeparators
.
get
(
chCode
);
if
(
chClass
===
CH_WHITESPACE
)
{
return
chIndex
;
...
...
@@ -2326,7 +2327,7 @@ class CursorHelper {
for
(
let
chIndex
=
position
.
column
-
1
;
chIndex
<
len
;
chIndex
++
)
{
let
chCode
=
lineContent
.
charCodeAt
(
chIndex
);
let
chClass
:
CharacterClass
=
(
wordSeparators
[
chCode
]
||
CharacterClass
.
Regular
);
let
chClass
=
wordSeparators
.
get
(
chCode
);
if
(
chClass
===
CH_REGULAR
)
{
if
(
wordType
===
W_SEPARATOR
)
{
...
...
@@ -2352,10 +2353,10 @@ class CursorHelper {
return
null
;
}
private
_findStartOfWord
(
lineContent
:
string
,
wordSeparators
:
CharacterClass
[]
,
wordType
:
WordType
,
startIndex
:
number
):
number
{
private
_findStartOfWord
(
lineContent
:
string
,
wordSeparators
:
WordCharacterClassifier
,
wordType
:
WordType
,
startIndex
:
number
):
number
{
for
(
let
chIndex
=
startIndex
;
chIndex
>=
0
;
chIndex
--
)
{
let
chCode
=
lineContent
.
charCodeAt
(
chIndex
);
let
chClass
:
CharacterClass
=
(
wordSeparators
[
chCode
]
||
CharacterClass
.
Regular
);
let
chClass
=
wordSeparators
.
get
(
chCode
);
if
(
chClass
===
CH_WHITESPACE
)
{
return
chIndex
+
1
;
...
...
@@ -2371,38 +2372,33 @@ class CursorHelper {
}
}
function
once
<
T
,
R
>
(
keyFn
:(
input
:
T
)
=>
string
,
computeFn
:(
input
:
T
)
=>
R
):(
input
:
T
)
=>
R
{
let
cache
:
{[
key
:
string
]:
R
;}
=
{};
return
(
input
:
T
):
R
=>
{
let
key
=
keyFn
(
input
);
if
(
!
cache
.
hasOwnProperty
(
key
))
{
cache
[
key
]
=
computeFn
(
input
);
}
return
cache
[
key
];
};
}
class
WordCharacterClassifier
extends
CharacterClassifier
<
CharacterClass
>
{
// TODO@Alex : Extract a fast Character Classifier
let
getMapForWordSeparators
=
once
<
string
,
CharacterClass
[]
>
(
(
input
)
=>
input
,
(
input
)
=>
{
constructor
(
wordSeparators
:
string
)
{
super
(
CharacterClass
.
Regular
);
let
r
:
CharacterClass
[]
=
[];
// Make array fast for ASCII text
for
(
let
chCode
=
0
;
chCode
<
256
;
chCode
++
)
{
r
[
chCode
]
=
CharacterClass
.
Regular
;
for
(
let
i
=
0
,
len
=
wordSeparators
.
length
;
i
<
len
;
i
++
)
{
this
.
set
(
wordSeparators
.
charCodeAt
(
i
),
CharacterClass
.
WordSeparator
);
}
for
(
let
i
=
0
,
len
=
input
.
length
;
i
<
len
;
i
++
)
{
r
[
input
.
charCodeAt
(
i
)]
=
CharacterClass
.
WordSeparator
;
}
this
.
set
(
CharCode
.
Space
,
CharacterClass
.
Whitespace
);
this
.
set
(
CharCode
.
Tab
,
CharacterClass
.
Whitespace
)
;
}
r
[
CharCode
.
Space
]
=
CharacterClass
.
Whitespace
;
r
[
CharCode
.
Tab
]
=
CharacterClass
.
Whitespace
;
}
return
r
;
}
function
once
<
R
>
(
computeFn
:(
input
:
string
)
=>
R
):(
input
:
string
)
=>
R
{
let
cache
:
{[
key
:
string
]:
R
;}
=
{};
// TODO@Alex unbounded cache
return
(
input
:
string
):
R
=>
{
if
(
!
cache
.
hasOwnProperty
(
input
))
{
cache
[
input
]
=
computeFn
(
input
);
}
return
cache
[
input
];
};
}
let
getMapForWordSeparators
=
once
<
WordCharacterClassifier
>
(
(
input
)
=>
new
WordCharacterClassifier
(
input
)
);
class
Utils
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录