Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
8e562d6d
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,发现更多精彩内容 >>
提交
8e562d6d
编写于
9月 12, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More CharCode work & adoption
上级
6fee06d6
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
348 addition
and
95 deletion
+348
-95
src/vs/base/common/charCode.ts
src/vs/base/common/charCode.ts
+164
-5
src/vs/base/test/common/charCode.test.ts
src/vs/base/test/common/charCode.test.ts
+122
-0
src/vs/editor/common/commands/shiftCommand.ts
src/vs/editor/common/commands/shiftCommand.ts
+3
-3
src/vs/editor/common/controller/cursorMoveHelper.ts
src/vs/editor/common/controller/cursorMoveHelper.ts
+4
-4
src/vs/editor/common/controller/oneCursor.ts
src/vs/editor/common/controller/oneCursor.ts
+5
-5
src/vs/editor/common/model/indentationGuesser.ts
src/vs/editor/common/model/indentationGuesser.ts
+5
-6
src/vs/editor/common/model/modelLine.ts
src/vs/editor/common/model/modelLine.ts
+3
-2
src/vs/editor/common/model/textModel.ts
src/vs/editor/common/model/textModel.ts
+3
-6
src/vs/editor/common/modes/abstractMode.ts
src/vs/editor/common/modes/abstractMode.ts
+38
-63
src/vs/platform/search/common/replace.ts
src/vs/platform/search/common/replace.ts
+1
-1
未找到文件。
src/vs/base/common/charCode.ts
浏览文件 @
8e562d6d
...
...
@@ -4,6 +4,8 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
// Names from https://blog.codinghorror.com/ascii-pronunciation-rules-for-programmers/
/**
* An inlined enum containing useful character codes (to be used with String.charCodeAt).
* Please leave the const keyword such that it gets inlined when compiled to JavaScript!
...
...
@@ -14,12 +16,62 @@ export const enum CharCode {
LineFeed
=
10
,
CarriageReturn
=
13
,
Space
=
32
,
/**
* The `!` character.
*/
ExclamationMark
=
33
,
/**
* The `"` character.
*/
DoubleQuote
=
34
,
/**
* The `#` character.
*/
Hash
=
35
,
/**
* The `$` character.
*/
Dollar
=
36
,
DollarSign
=
36
,
/**
* The `%` character.
*/
PercentSign
=
37
,
/**
* The `&` character.
*/
Ampersand
=
38
,
/**
* The `'` character.
*/
SingleQuote
=
39
,
/**
* The `(` character.
*/
OpenParen
=
40
,
/**
* The `)` character.
*/
CloseParen
=
41
,
/**
* The `*` character.
*/
Asterisk
=
42
,
/**
* The `+` character.
*/
Plus
=
43
,
/**
* The `,` character.
*/
Comma
=
44
,
/**
* The `-` character.
*/
Dash
=
45
,
/**
* The `.` character.
*/
Period
=
46
,
/**
* The `/` character.
*/
...
...
@@ -27,30 +79,137 @@ export const enum CharCode {
Digit0
=
48
,
Digit1
=
49
,
Digit2
=
50
,
Digit3
=
51
,
Digit4
=
52
,
Digit5
=
53
,
Digit6
=
54
,
Digit7
=
55
,
Digit8
=
56
,
Digit9
=
57
,
/**
* The `:` character.
*/
Colon
=
58
,
/**
* The `;` character.
*/
Semicolon
=
59
,
/**
* The `<` character.
*/
LessThan
=
60
,
/**
* The `=` character.
*/
Equals
=
61
,
/**
* The `>` character.
*/
GreaterThan
=
62
,
/**
* The `?` character.
*/
QuestionMark
=
63
,
/**
* The `@` character.
*/
AtSign
=
64
,
A
=
65
,
B
=
66
,
C
=
67
,
D
=
68
,
E
=
69
,
F
=
70
,
G
=
71
,
H
=
72
,
I
=
73
,
J
=
74
,
K
=
75
,
L
=
76
,
M
=
77
,
N
=
78
,
O
=
79
,
P
=
80
,
Q
=
81
,
R
=
82
,
S
=
83
,
T
=
84
,
U
=
85
,
V
=
86
,
W
=
87
,
X
=
88
,
Y
=
89
,
Z
=
90
,
/**
* The `[` character.
*/
OpenSquareBracket
=
91
,
/**
* The `\` character.
*/
Backslash
=
92
,
/**
* The `]` character.
*/
CloseSquareBracket
=
93
,
/**
* The `^` character.
*/
Caret
=
94
,
/**
* The `_` character.
*/
Underline
=
95
,
/**
* The ``(`)`` character.
*/
BackTick
=
96
,
a
=
97
,
b
=
98
,
c
=
99
,
d
=
100
,
e
=
101
,
f
=
102
,
g
=
103
,
h
=
104
,
i
=
105
,
j
=
106
,
k
=
107
,
l
=
108
,
m
=
109
,
n
=
110
,
o
=
111
,
p
=
112
,
q
=
113
,
r
=
114
,
s
=
115
,
t
=
116
,
u
=
117
,
v
=
118
,
w
=
119
,
x
=
120
,
y
=
121
,
z
=
122
,
/**
* The `{` character.
*/
OpenCurlyBrace
=
123
,
/**
* The `|` character.
*/
Pipe
=
124
,
/**
* The `}` character.
*/
CloseCurlyBrace
=
125
,
/**
* The `~` character.
*/
Tilde
=
126
,
}
\ No newline at end of file
src/vs/base/test/common/charCode.test.ts
0 → 100644
浏览文件 @
8e562d6d
/*---------------------------------------------------------------------------------------------
* 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
assert
from
'
assert
'
;
import
{
CharCode
}
from
'
vs/base/common/charCode
'
;
suite
(
'
CharCode
'
,
()
=>
{
test
(
'
has good values
'
,
()
=>
{
function
assertValue
(
actual
:
CharCode
,
expected
:
string
):
void
{
assert
.
equal
(
actual
,
expected
.
charCodeAt
(
0
),
'
char code ok for <<
'
+
expected
+
'
>>
'
);
}
assertValue
(
CharCode
.
Tab
,
'
\t
'
);
assertValue
(
CharCode
.
LineFeed
,
'
\n
'
);
assertValue
(
CharCode
.
CarriageReturn
,
'
\r
'
);
assertValue
(
CharCode
.
Space
,
'
'
);
assertValue
(
CharCode
.
ExclamationMark
,
'
!
'
);
assertValue
(
CharCode
.
DoubleQuote
,
'
"
'
);
assertValue
(
CharCode
.
Hash
,
'
#
'
);
assertValue
(
CharCode
.
DollarSign
,
'
$
'
);
assertValue
(
CharCode
.
PercentSign
,
'
%
'
);
assertValue
(
CharCode
.
Ampersand
,
'
&
'
);
assertValue
(
CharCode
.
SingleQuote
,
'
\'
'
);
assertValue
(
CharCode
.
OpenParen
,
'
(
'
);
assertValue
(
CharCode
.
CloseParen
,
'
)
'
);
assertValue
(
CharCode
.
Asterisk
,
'
*
'
);
assertValue
(
CharCode
.
Plus
,
'
+
'
);
assertValue
(
CharCode
.
Comma
,
'
,
'
);
assertValue
(
CharCode
.
Dash
,
'
-
'
);
assertValue
(
CharCode
.
Period
,
'
.
'
);
assertValue
(
CharCode
.
Slash
,
'
/
'
);
assertValue
(
CharCode
.
Digit0
,
'
0
'
);
assertValue
(
CharCode
.
Digit1
,
'
1
'
);
assertValue
(
CharCode
.
Digit2
,
'
2
'
);
assertValue
(
CharCode
.
Digit3
,
'
3
'
);
assertValue
(
CharCode
.
Digit4
,
'
4
'
);
assertValue
(
CharCode
.
Digit5
,
'
5
'
);
assertValue
(
CharCode
.
Digit6
,
'
6
'
);
assertValue
(
CharCode
.
Digit7
,
'
7
'
);
assertValue
(
CharCode
.
Digit8
,
'
8
'
);
assertValue
(
CharCode
.
Digit9
,
'
9
'
);
assertValue
(
CharCode
.
Colon
,
'
:
'
);
assertValue
(
CharCode
.
Semicolon
,
'
;
'
);
assertValue
(
CharCode
.
LessThan
,
'
<
'
);
assertValue
(
CharCode
.
Equals
,
'
=
'
);
assertValue
(
CharCode
.
GreaterThan
,
'
>
'
);
assertValue
(
CharCode
.
QuestionMark
,
'
?
'
);
assertValue
(
CharCode
.
AtSign
,
'
@
'
);
assertValue
(
CharCode
.
A
,
'
A
'
);
assertValue
(
CharCode
.
B
,
'
B
'
);
assertValue
(
CharCode
.
C
,
'
C
'
);
assertValue
(
CharCode
.
D
,
'
D
'
);
assertValue
(
CharCode
.
E
,
'
E
'
);
assertValue
(
CharCode
.
F
,
'
F
'
);
assertValue
(
CharCode
.
G
,
'
G
'
);
assertValue
(
CharCode
.
H
,
'
H
'
);
assertValue
(
CharCode
.
I
,
'
I
'
);
assertValue
(
CharCode
.
J
,
'
J
'
);
assertValue
(
CharCode
.
K
,
'
K
'
);
assertValue
(
CharCode
.
L
,
'
L
'
);
assertValue
(
CharCode
.
M
,
'
M
'
);
assertValue
(
CharCode
.
N
,
'
N
'
);
assertValue
(
CharCode
.
O
,
'
O
'
);
assertValue
(
CharCode
.
P
,
'
P
'
);
assertValue
(
CharCode
.
Q
,
'
Q
'
);
assertValue
(
CharCode
.
R
,
'
R
'
);
assertValue
(
CharCode
.
S
,
'
S
'
);
assertValue
(
CharCode
.
T
,
'
T
'
);
assertValue
(
CharCode
.
U
,
'
U
'
);
assertValue
(
CharCode
.
V
,
'
V
'
);
assertValue
(
CharCode
.
W
,
'
W
'
);
assertValue
(
CharCode
.
X
,
'
X
'
);
assertValue
(
CharCode
.
Y
,
'
Y
'
);
assertValue
(
CharCode
.
Z
,
'
Z
'
);
assertValue
(
CharCode
.
OpenSquareBracket
,
'
[
'
);
assertValue
(
CharCode
.
Backslash
,
'
\\
'
);
assertValue
(
CharCode
.
CloseSquareBracket
,
'
]
'
);
assertValue
(
CharCode
.
Caret
,
'
^
'
);
assertValue
(
CharCode
.
Underline
,
'
_
'
);
assertValue
(
CharCode
.
BackTick
,
'
`
'
);
assertValue
(
CharCode
.
a
,
'
a
'
);
assertValue
(
CharCode
.
b
,
'
b
'
);
assertValue
(
CharCode
.
c
,
'
c
'
);
assertValue
(
CharCode
.
d
,
'
d
'
);
assertValue
(
CharCode
.
e
,
'
e
'
);
assertValue
(
CharCode
.
f
,
'
f
'
);
assertValue
(
CharCode
.
g
,
'
g
'
);
assertValue
(
CharCode
.
h
,
'
h
'
);
assertValue
(
CharCode
.
i
,
'
i
'
);
assertValue
(
CharCode
.
j
,
'
j
'
);
assertValue
(
CharCode
.
k
,
'
k
'
);
assertValue
(
CharCode
.
l
,
'
l
'
);
assertValue
(
CharCode
.
m
,
'
m
'
);
assertValue
(
CharCode
.
n
,
'
n
'
);
assertValue
(
CharCode
.
o
,
'
o
'
);
assertValue
(
CharCode
.
p
,
'
p
'
);
assertValue
(
CharCode
.
q
,
'
q
'
);
assertValue
(
CharCode
.
r
,
'
r
'
);
assertValue
(
CharCode
.
s
,
'
s
'
);
assertValue
(
CharCode
.
t
,
'
t
'
);
assertValue
(
CharCode
.
u
,
'
u
'
);
assertValue
(
CharCode
.
v
,
'
v
'
);
assertValue
(
CharCode
.
w
,
'
w
'
);
assertValue
(
CharCode
.
x
,
'
x
'
);
assertValue
(
CharCode
.
y
,
'
y
'
);
assertValue
(
CharCode
.
z
,
'
z
'
);
assertValue
(
CharCode
.
OpenCurlyBrace
,
'
{
'
);
assertValue
(
CharCode
.
Pipe
,
'
|
'
);
assertValue
(
CharCode
.
CloseCurlyBrace
,
'
}
'
);
assertValue
(
CharCode
.
Tilde
,
'
~
'
);
});
});
src/vs/editor/common/commands/shiftCommand.ts
浏览文件 @
8e562d6d
...
...
@@ -10,6 +10,7 @@ import {Range} from 'vs/editor/common/core/range';
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
ICommand
,
ICursorStateComputerData
,
IEditOperationBuilder
,
ITokenizedModel
}
from
'
vs/editor/common/editorCommon
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
CharCode
}
from
'
vs/base/common/charCode
'
;
export
interface
IShiftCommandOpts
{
isUnshift
:
boolean
;
...
...
@@ -53,7 +54,6 @@ export class ShiftCommand implements ICommand {
public
getEditOperations
(
model
:
ITokenizedModel
,
builder
:
IEditOperationBuilder
):
void
{
let
startLine
=
this
.
_selection
.
startLineNumber
;
let
endLine
=
this
.
_selection
.
endLineNumber
;
let
_SPACE
=
'
'
.
charCodeAt
(
0
);
if
(
this
.
_selection
.
endColumn
===
1
&&
startLine
!==
endLine
)
{
endLine
=
endLine
-
1
;
...
...
@@ -106,7 +106,7 @@ export class ShiftCommand implements ICommand {
extraSpaces
=
previousLineExtraSpaces
;
if
(
enterAction
.
appendText
)
{
for
(
let
j
=
0
,
lenJ
=
enterAction
.
appendText
.
length
;
j
<
lenJ
&&
extraSpaces
<
tabSize
;
j
++
)
{
if
(
enterAction
.
appendText
.
charCodeAt
(
j
)
===
_SPACE
)
{
if
(
enterAction
.
appendText
.
charCodeAt
(
j
)
===
CharCode
.
Space
)
{
extraSpaces
++
;
}
else
{
break
;
...
...
@@ -119,7 +119,7 @@ export class ShiftCommand implements ICommand {
// Act as if `prefixSpaces` is not part of the indentation
for
(
let
j
=
0
;
j
<
extraSpaces
;
j
++
)
{
if
(
indentationEndIndex
===
0
||
lineText
.
charCodeAt
(
indentationEndIndex
-
1
)
!==
_SPACE
)
{
if
(
indentationEndIndex
===
0
||
lineText
.
charCodeAt
(
indentationEndIndex
-
1
)
!==
CharCode
.
Space
)
{
break
;
}
indentationEndIndex
--
;
...
...
src/vs/editor/common/controller/cursorMoveHelper.ts
浏览文件 @
8e562d6d
...
...
@@ -50,13 +50,13 @@ export interface IConfiguration {
getIndentationOptions
():
IInternalIndentationOptions
;
}
function
isHighSurrogate
(
model
,
lineNumber
,
column
)
{
var
code
=
model
.
getLineContent
(
lineNumber
).
charCodeAt
(
column
-
1
);
function
isHighSurrogate
(
model
:
ICursorMoveHelperModel
,
lineNumber
:
number
,
column
:
number
)
{
let
code
=
model
.
getLineContent
(
lineNumber
).
charCodeAt
(
column
-
1
);
return
0xD800
<=
code
&&
code
<=
0xDBFF
;
}
function
isLowSurrogate
(
model
,
lineNumber
,
column
)
{
var
code
=
model
.
getLineContent
(
lineNumber
).
charCodeAt
(
column
-
1
);
function
isLowSurrogate
(
model
:
ICursorMoveHelperModel
,
lineNumber
:
number
,
column
:
number
)
{
let
code
=
model
.
getLineContent
(
lineNumber
).
charCodeAt
(
column
-
1
);
return
0xDC00
<=
code
&&
code
<=
0xDFFF
;
}
...
...
src/vs/editor/common/controller/oneCursor.ts
浏览文件 @
8e562d6d
...
...
@@ -16,6 +16,7 @@ import {Selection, SelectionDirection} from 'vs/editor/common/core/selection';
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
'
;
export
interface
IPostOperationRunnable
{
(
ctx
:
IOneCursorOperationContext
):
void
;
...
...
@@ -1528,8 +1529,6 @@ export class OneCursorOp {
}
let
selectionContainsOnlyWhitespace
=
true
;
let
_tab
=
'
\t
'
.
charCodeAt
(
0
);
let
_space
=
'
'
.
charCodeAt
(
0
);
for
(
let
lineNumber
=
selection
.
startLineNumber
;
lineNumber
<=
selection
.
endLineNumber
;
lineNumber
++
)
{
let
lineText
=
cursor
.
model
.
getLineContent
(
lineNumber
);
...
...
@@ -1537,7 +1536,7 @@ export class OneCursorOp {
let
endIndex
=
(
lineNumber
===
selection
.
endLineNumber
?
selection
.
endColumn
-
1
:
lineText
.
length
);
for
(
let
charIndex
=
startIndex
;
charIndex
<
endIndex
;
charIndex
++
)
{
let
charCode
=
lineText
.
charCodeAt
(
charIndex
);
if
(
charCode
!==
_tab
&&
charCode
!==
_s
pace
)
{
if
(
charCode
!==
CharCode
.
Tab
&&
charCode
!==
CharCode
.
S
pace
)
{
selectionContainsOnlyWhitespace
=
false
;
// Break outer loop
...
...
@@ -2383,6 +2382,7 @@ function once<T, R>(keyFn:(input:T)=>string, computeFn:(input:T)=>R):(input:T)=>
};
}
// TODO@Alex : Extract a fast Character Classifier
let
getMapForWordSeparators
=
once
<
string
,
CharacterClass
[]
>
(
(
input
)
=>
input
,
(
input
)
=>
{
...
...
@@ -2398,8 +2398,8 @@ let getMapForWordSeparators = once<string,CharacterClass[]>(
r
[
input
.
charCodeAt
(
i
)]
=
CharacterClass
.
WordSeparator
;
}
r
[
'
'
.
charCodeAt
(
0
)
]
=
CharacterClass
.
Whitespace
;
r
[
'
\t
'
.
charCodeAt
(
0
)
]
=
CharacterClass
.
Whitespace
;
r
[
CharCode
.
Space
]
=
CharacterClass
.
Whitespace
;
r
[
CharCode
.
Tab
]
=
CharacterClass
.
Whitespace
;
return
r
;
}
...
...
src/vs/editor/common/model/indentationGuesser.ts
浏览文件 @
8e562d6d
...
...
@@ -4,8 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
const
__space
=
'
'
.
charCodeAt
(
0
);
const
__tab
=
'
\t
'
.
charCodeAt
(
0
);
import
{
CharCode
}
from
'
vs/base/common/charCode
'
;
/**
* Compute the diff in spaces between two line's indentation.
...
...
@@ -31,7 +30,7 @@ function spacesDiff(a:string, aLength:number, b:string, bLength:number): number
let
aSpacesCnt
=
0
,
aTabsCount
=
0
;
for
(
let
j
=
i
;
j
<
aLength
;
j
++
)
{
let
aCharCode
=
a
.
charCodeAt
(
j
);
if
(
aCharCode
===
__s
pace
)
{
if
(
aCharCode
===
CharCode
.
S
pace
)
{
aSpacesCnt
++
;
}
else
{
aTabsCount
++
;
...
...
@@ -41,7 +40,7 @@ function spacesDiff(a:string, aLength:number, b:string, bLength:number): number
let
bSpacesCnt
=
0
,
bTabsCount
=
0
;
for
(
let
j
=
i
;
j
<
bLength
;
j
++
)
{
let
bCharCode
=
b
.
charCodeAt
(
j
);
if
(
bCharCode
===
__s
pace
)
{
if
(
bCharCode
===
CharCode
.
S
pace
)
{
bSpacesCnt
++
;
}
else
{
bTabsCount
++
;
...
...
@@ -103,9 +102,9 @@ export function guessIndentation(lines:string[], defaultTabSize:number, defaultI
for
(
let
j
=
0
,
lenJ
=
currentLineText
.
length
;
j
<
lenJ
;
j
++
)
{
let
charCode
=
currentLineText
.
charCodeAt
(
j
);
if
(
charCode
===
__t
ab
)
{
if
(
charCode
===
CharCode
.
T
ab
)
{
currentLineTabsCount
++
;
}
else
if
(
charCode
===
__s
pace
)
{
}
else
if
(
charCode
===
CharCode
.
S
pace
)
{
currentLineSpacesCount
++
;
}
else
{
// Hit non whitespace character on this line
...
...
src/vs/editor/common/model/modelLine.ts
浏览文件 @
8e562d6d
...
...
@@ -11,6 +11,7 @@ import {TokensBinaryEncoding, TokensInflatorMap} from 'vs/editor/common/model/to
import
{
ModeTransition
}
from
'
vs/editor/common/core/modeTransition
'
;
import
{
Token
}
from
'
vs/editor/common/core/token
'
;
import
{
ViewLineToken
}
from
'
vs/editor/common/core/viewLineToken
'
;
import
{
CharCode
}
from
'
vs/base/common/charCode
'
;
const
START_INDEX_MASK
=
TokensBinaryEncoding
.
START_INDEX_MASK
;
const
TYPE_MASK
=
TokensBinaryEncoding
.
TYPE_MASK
;
...
...
@@ -83,9 +84,9 @@ function computePlusOneIndentLevel(line: string, tabSize: number): number {
while
(
i
<
len
)
{
let
chCode
=
line
.
charCodeAt
(
i
);
if
(
chCode
===
32
/*space*/
)
{
if
(
chCode
===
CharCode
.
Space
)
{
indent
++
;
}
else
if
(
chCode
===
9
/*\t*/
)
{
}
else
if
(
chCode
===
CharCode
.
Tab
)
{
indent
=
indent
-
indent
%
tabSize
+
tabSize
;
}
else
{
break
;
...
...
src/vs/editor/common/model/textModel.ts
浏览文件 @
8e562d6d
...
...
@@ -14,6 +14,7 @@ import {guessIndentation} from 'vs/editor/common/model/indentationGuesser';
import
{
DEFAULT_INDENTATION
,
DEFAULT_TRIM_AUTO_WHITESPACE
}
from
'
vs/editor/common/config/defaultConfig
'
;
import
{
PrefixSumComputer
}
from
'
vs/editor/common/viewModel/prefixSumComputer
'
;
import
{
IndentRange
,
computeRanges
}
from
'
vs/editor/common/model/indentRanges
'
;
import
{
CharCode
}
from
'
vs/base/common/charCode
'
;
const
LIMIT_FIND_COUNT
=
999
;
export
const
LONG_LINE_BOUNDARY
=
1000
;
...
...
@@ -728,10 +729,6 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
}
private
static
_isMultiline
(
searchString
:
string
):
boolean
{
const
BACKSLASH_CHAR_CODE
=
'
\\
'
.
charCodeAt
(
0
);
const
n_CHAR_CODE
=
'
n
'
.
charCodeAt
(
0
);
const
r_CHAR_CODE
=
'
r
'
.
charCodeAt
(
0
);
if
(
!
searchString
||
searchString
.
length
===
0
)
{
return
false
;
}
...
...
@@ -739,7 +736,7 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
for
(
let
i
=
0
,
len
=
searchString
.
length
;
i
<
len
;
i
++
)
{
let
chCode
=
searchString
.
charCodeAt
(
i
);
if
(
chCode
===
BACKSLASH_CHAR_CODE
)
{
if
(
chCode
===
CharCode
.
Backslash
)
{
// move to next char
i
++
;
...
...
@@ -750,7 +747,7 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
}
let
nextChCode
=
searchString
.
charCodeAt
(
i
);
if
(
nextChCode
===
n_CHAR_CODE
||
nextChCode
===
r_CHAR_CODE
)
{
if
(
nextChCode
===
CharCode
.
n
||
nextChCode
===
CharCode
.
r
)
{
return
true
;
}
}
...
...
src/vs/editor/common/modes/abstractMode.ts
浏览文件 @
8e562d6d
...
...
@@ -16,6 +16,7 @@ import {TextualSuggestSupport} from 'vs/editor/common/modes/supports/suggestSupp
import
{
IEditorWorkerService
}
from
'
vs/editor/common/services/editorWorkerService
'
;
import
*
as
wordHelper
from
'
vs/editor/common/model/wordHelper
'
;
import
{
ICompatWorkerService
,
ICompatMode
}
from
'
vs/editor/common/services/compatWorkerService
'
;
import
{
CharCode
}
from
'
vs/base/common/charCode
'
;
export
function
createWordRegExp
(
allowInWords
:
string
=
''
):
RegExp
{
return
wordHelper
.
createWordRegExp
(
allowInWords
);
...
...
@@ -170,69 +171,43 @@ class SimplifiedMode implements modes.IMode {
}
}
export
var
isDigit
:(
character
:
string
,
base
:
number
)
=>
boolean
=
(
function
()
{
var
_0
=
'
0
'
.
charCodeAt
(
0
),
_1
=
'
1
'
.
charCodeAt
(
0
),
_2
=
'
2
'
.
charCodeAt
(
0
),
_3
=
'
3
'
.
charCodeAt
(
0
),
_4
=
'
4
'
.
charCodeAt
(
0
),
_5
=
'
5
'
.
charCodeAt
(
0
),
_6
=
'
6
'
.
charCodeAt
(
0
),
_7
=
'
7
'
.
charCodeAt
(
0
),
_8
=
'
8
'
.
charCodeAt
(
0
),
_9
=
'
9
'
.
charCodeAt
(
0
),
_a
=
'
a
'
.
charCodeAt
(
0
),
_b
=
'
b
'
.
charCodeAt
(
0
),
_c
=
'
c
'
.
charCodeAt
(
0
),
_d
=
'
d
'
.
charCodeAt
(
0
),
_e
=
'
e
'
.
charCodeAt
(
0
),
_f
=
'
f
'
.
charCodeAt
(
0
),
_A
=
'
A
'
.
charCodeAt
(
0
),
_B
=
'
B
'
.
charCodeAt
(
0
),
_C
=
'
C
'
.
charCodeAt
(
0
),
_D
=
'
D
'
.
charCodeAt
(
0
),
_E
=
'
E
'
.
charCodeAt
(
0
),
_F
=
'
F
'
.
charCodeAt
(
0
);
return
function
isDigit
(
character
:
string
,
base
:
number
):
boolean
{
var
c
=
character
.
charCodeAt
(
0
);
switch
(
base
)
{
case
1
:
return
c
===
_0
;
case
2
:
return
c
>=
_0
&&
c
<=
_1
;
case
3
:
return
c
>=
_0
&&
c
<=
_2
;
case
4
:
return
c
>=
_0
&&
c
<=
_3
;
case
5
:
return
c
>=
_0
&&
c
<=
_4
;
case
6
:
return
c
>=
_0
&&
c
<=
_5
;
case
7
:
return
c
>=
_0
&&
c
<=
_6
;
case
8
:
return
c
>=
_0
&&
c
<=
_7
;
case
9
:
return
c
>=
_0
&&
c
<=
_8
;
case
10
:
return
c
>=
_0
&&
c
<=
_9
;
case
11
:
return
(
c
>=
_0
&&
c
<=
_9
)
||
(
c
===
_a
)
||
(
c
===
_A
);
case
12
:
return
(
c
>=
_0
&&
c
<=
_9
)
||
(
c
>=
_a
&&
c
<=
_b
)
||
(
c
>=
_A
&&
c
<=
_B
);
case
13
:
return
(
c
>=
_0
&&
c
<=
_9
)
||
(
c
>=
_a
&&
c
<=
_c
)
||
(
c
>=
_A
&&
c
<=
_C
);
case
14
:
return
(
c
>=
_0
&&
c
<=
_9
)
||
(
c
>=
_a
&&
c
<=
_d
)
||
(
c
>=
_A
&&
c
<=
_D
);
case
15
:
return
(
c
>=
_0
&&
c
<=
_9
)
||
(
c
>=
_a
&&
c
<=
_e
)
||
(
c
>=
_A
&&
c
<=
_E
);
default
:
return
(
c
>=
_0
&&
c
<=
_9
)
||
(
c
>=
_a
&&
c
<=
_f
)
||
(
c
>=
_A
&&
c
<=
_F
);
}
};
})();
export
function
isDigit
(
character
:
string
,
base
:
number
):
boolean
{
var
c
=
character
.
charCodeAt
(
0
);
switch
(
base
)
{
case
1
:
return
c
===
CharCode
.
Digit0
;
case
2
:
return
c
>=
CharCode
.
Digit0
&&
c
<=
CharCode
.
Digit1
;
case
3
:
return
c
>=
CharCode
.
Digit0
&&
c
<=
CharCode
.
Digit2
;
case
4
:
return
c
>=
CharCode
.
Digit0
&&
c
<=
CharCode
.
Digit3
;
case
5
:
return
c
>=
CharCode
.
Digit0
&&
c
<=
CharCode
.
Digit4
;
case
6
:
return
c
>=
CharCode
.
Digit0
&&
c
<=
CharCode
.
Digit5
;
case
7
:
return
c
>=
CharCode
.
Digit0
&&
c
<=
CharCode
.
Digit6
;
case
8
:
return
c
>=
CharCode
.
Digit0
&&
c
<=
CharCode
.
Digit7
;
case
9
:
return
c
>=
CharCode
.
Digit0
&&
c
<=
CharCode
.
Digit8
;
case
10
:
return
c
>=
CharCode
.
Digit0
&&
c
<=
CharCode
.
Digit9
;
case
11
:
return
(
c
>=
CharCode
.
Digit0
&&
c
<=
CharCode
.
Digit9
)
||
(
c
===
CharCode
.
a
)
||
(
c
===
CharCode
.
A
);
case
12
:
return
(
c
>=
CharCode
.
Digit0
&&
c
<=
CharCode
.
Digit9
)
||
(
c
>=
CharCode
.
a
&&
c
<=
CharCode
.
b
)
||
(
c
>=
CharCode
.
A
&&
c
<=
CharCode
.
B
);
case
13
:
return
(
c
>=
CharCode
.
Digit0
&&
c
<=
CharCode
.
Digit9
)
||
(
c
>=
CharCode
.
a
&&
c
<=
CharCode
.
c
)
||
(
c
>=
CharCode
.
A
&&
c
<=
CharCode
.
C
);
case
14
:
return
(
c
>=
CharCode
.
Digit0
&&
c
<=
CharCode
.
Digit9
)
||
(
c
>=
CharCode
.
a
&&
c
<=
CharCode
.
d
)
||
(
c
>=
CharCode
.
A
&&
c
<=
CharCode
.
D
);
case
15
:
return
(
c
>=
CharCode
.
Digit0
&&
c
<=
CharCode
.
Digit9
)
||
(
c
>=
CharCode
.
a
&&
c
<=
CharCode
.
e
)
||
(
c
>=
CharCode
.
A
&&
c
<=
CharCode
.
E
);
default
:
return
(
c
>=
CharCode
.
Digit0
&&
c
<=
CharCode
.
Digit9
)
||
(
c
>=
CharCode
.
a
&&
c
<=
CharCode
.
f
)
||
(
c
>=
CharCode
.
A
&&
c
<=
CharCode
.
F
);
}
}
export
class
FrankensteinMode
extends
AbstractMode
{
...
...
src/vs/platform/search/common/replace.ts
浏览文件 @
8e562d6d
...
...
@@ -119,7 +119,7 @@ export class ReplacePattern {
}
}
if
(
chCode
===
CharCode
.
Dollar
)
{
if
(
chCode
===
CharCode
.
Dollar
Sign
)
{
// move to next char
i
++
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录