Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
dd741194
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dd741194
编写于
1月 25, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove TextAreaState.extractNewText() and extractMacReplacedText()
上级
a1bd50f6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
34 addition
and
116 deletion
+34
-116
src/vs/editor/common/controller/textAreaState.ts
src/vs/editor/common/controller/textAreaState.ts
+0
-50
src/vs/editor/test/common/controller/textAreaState.test.ts
src/vs/editor/test/common/controller/textAreaState.test.ts
+34
-66
未找到文件。
src/vs/editor/common/controller/textAreaState.ts
浏览文件 @
dd741194
...
...
@@ -172,56 +172,6 @@ export abstract class TextAreaState {
replaceCharCnt
:
replacePreviousCharacters
};
}
public
extractNewText
():
string
{
// console.log('-----------')
// console.log('prev:' + String(previousState));
// console.log('curr:' + String(this));
if
(
this
.
selectionStart
!==
this
.
selectionEnd
)
{
// There is a selection in the textarea => ignore input
return
''
;
}
if
(
!
this
.
previousState
)
{
return
this
.
value
;
}
let
previousPrefix
=
this
.
previousState
.
value
.
substring
(
0
,
this
.
previousState
.
selectionStart
);
let
previousSuffix
=
this
.
previousState
.
value
.
substring
(
this
.
previousState
.
selectionEnd
,
this
.
previousState
.
value
.
length
);
if
(
this
.
isInOverwriteMode
)
{
previousSuffix
=
previousSuffix
.
substr
(
1
);
}
let
value
=
this
.
value
;
if
(
value
.
substring
(
0
,
previousPrefix
.
length
)
===
previousPrefix
)
{
value
=
value
.
substring
(
previousPrefix
.
length
);
}
if
(
value
.
substring
(
value
.
length
-
previousSuffix
.
length
,
value
.
length
)
===
previousSuffix
)
{
value
=
value
.
substring
(
0
,
value
.
length
-
previousSuffix
.
length
);
}
return
value
;
}
public
extractMacReplacedText
():
string
{
// Ignore if the textarea has selection
if
(
this
.
selectionStart
!==
this
.
selectionEnd
)
{
return
''
;
}
if
(
!
this
.
previousState
)
{
return
''
;
}
if
(
this
.
previousState
.
value
.
length
!==
this
.
value
.
length
)
{
return
''
;
}
let
prefixLength
=
commonPrefixLength
(
this
.
previousState
.
value
,
this
.
value
);
let
suffixLength
=
commonSuffixLength
(
this
.
previousState
.
value
,
this
.
value
);
if
(
prefixLength
+
suffixLength
+
1
!==
this
.
value
.
length
)
{
return
''
;
}
return
this
.
value
.
charAt
(
prefixLength
);
}
}
export
class
IENarratorTextAreaState
extends
TextAreaState
{
...
...
src/vs/editor/test/common/controller/textAreaState.test.ts
浏览文件 @
dd741194
...
...
@@ -221,161 +221,129 @@ suite('TextAreaState', () => {
);
});
function
testExtractNewText
(
prevState
:
TextAreaState
,
value
:
string
,
selectionStart
:
number
,
selectionEnd
:
number
,
isInOverwriteMode
:
boolean
,
expected
:
string
):
void
{
let
textArea
=
new
MockTextAreaWrapper
();
textArea
.
_value
=
value
;
textArea
.
_selectionStart
=
selectionStart
;
textArea
.
_selectionEnd
=
selectionEnd
;
textArea
.
_isInOverwriteMode
=
isInOverwriteMode
;
let
newState
=
(
prevState
||
IENarratorTextAreaState
.
EMPTY
).
fromTextArea
(
textArea
);
let
actual
=
newState
.
extractNewText
();
assert
.
equal
(
actual
,
expected
);
textArea
.
dispose
();
}
test
(
'
extractNewText - no previous state with selection
'
,
()
=>
{
test
ExtractNewTex
t
(
test
DeduceInpu
t
(
null
,
'
a
'
,
0
,
1
,
false
,
'
'
'
a
'
,
0
);
});
test
(
'
extractNewText - no previous state without selection
'
,
()
=>
{
test
ExtractNewTex
t
(
test
DeduceInpu
t
(
null
,
'
a
'
,
1
,
1
,
false
,
'
a
'
'
a
'
,
0
);
});
test
(
'
extractNewText - typing does not cause a selection
'
,
()
=>
{
test
ExtractNewTex
t
(
test
DeduceInpu
t
(
new
IENarratorTextAreaState
(
null
,
''
,
0
,
0
,
false
,
0
),
'
a
'
,
0
,
1
,
false
,
'
'
'
a
'
,
0
);
});
test
(
'
extractNewText - had the textarea empty
'
,
()
=>
{
test
ExtractNewTex
t
(
test
DeduceInpu
t
(
new
IENarratorTextAreaState
(
null
,
''
,
0
,
0
,
false
,
0
),
'
a
'
,
1
,
1
,
false
,
'
a
'
'
a
'
,
0
);
});
test
(
'
extractNewText - had the entire line selected
'
,
()
=>
{
test
ExtractNewTex
t
(
test
DeduceInpu
t
(
new
IENarratorTextAreaState
(
null
,
'
Hello world!
'
,
0
,
12
,
false
,
0
),
'
H
'
,
1
,
1
,
false
,
'
H
'
'
H
'
,
0
);
});
test
(
'
extractNewText - had previous text 1
'
,
()
=>
{
test
ExtractNewTex
t
(
test
DeduceInpu
t
(
new
IENarratorTextAreaState
(
null
,
'
Hello world!
'
,
12
,
12
,
false
,
0
),
'
Hello world!a
'
,
13
,
13
,
false
,
'
a
'
'
a
'
,
0
);
});
test
(
'
extractNewText - had previous text 2
'
,
()
=>
{
test
ExtractNewTex
t
(
test
DeduceInpu
t
(
new
IENarratorTextAreaState
(
null
,
'
Hello world!
'
,
0
,
0
,
false
,
0
),
'
aHello world!
'
,
1
,
1
,
false
,
'
a
'
'
a
'
,
0
);
});
test
(
'
extractNewText - had previous text 3
'
,
()
=>
{
test
ExtractNewTex
t
(
test
DeduceInpu
t
(
new
IENarratorTextAreaState
(
null
,
'
Hello world!
'
,
6
,
11
,
false
,
0
),
'
Hello other!
'
,
11
,
11
,
false
,
'
other
'
'
other
'
,
0
);
});
test
(
'
extractNewText - IME
'
,
()
=>
{
test
ExtractNewTex
t
(
test
DeduceInpu
t
(
new
IENarratorTextAreaState
(
null
,
''
,
0
,
0
,
false
,
0
),
'
これは
'
,
3
,
3
,
false
,
'
これは
'
'
これは
'
,
0
);
});
test
(
'
extractNewText - isInOverwriteMode
'
,
()
=>
{
test
ExtractNewTex
t
(
test
DeduceInpu
t
(
new
IENarratorTextAreaState
(
null
,
'
Hello world!
'
,
0
,
0
,
false
,
0
),
'
Aello world!
'
,
1
,
1
,
true
,
'
A
'
'
A
'
,
0
);
});
function
testExtractMacReplacedText
(
prevState
:
TextAreaState
,
value
:
string
,
selectionStart
:
number
,
selectionEnd
:
number
,
isInOverwriteMode
:
boolean
,
expected
:
string
):
void
{
let
textArea
=
new
MockTextAreaWrapper
();
textArea
.
_value
=
value
;
textArea
.
_selectionStart
=
selectionStart
;
textArea
.
_selectionEnd
=
selectionEnd
;
textArea
.
_isInOverwriteMode
=
isInOverwriteMode
;
let
newState
=
(
prevState
||
IENarratorTextAreaState
.
EMPTY
).
fromTextArea
(
textArea
);
let
actual
=
newState
.
extractMacReplacedText
();
assert
.
equal
(
actual
,
expected
);
textArea
.
dispose
();
}
test
(
'
extractMacReplacedText - does nothing if there is selection
'
,
()
=>
{
test
ExtractMacReplacedTex
t
(
new
IENarratorTextAreaState
(
null
,
'
Hello world!
'
,
0
,
0
,
false
,
0
),
test
DeduceInpu
t
(
new
IENarratorTextAreaState
(
null
,
'
Hello world!
'
,
5
,
5
,
false
,
0
),
'
Hellö world!
'
,
4
,
5
,
false
,
'
'
'
ö
'
,
0
);
});
test
(
'
extractMacReplacedText - does nothing if there is more than one extra char
'
,
()
=>
{
test
ExtractMacReplacedTex
t
(
new
IENarratorTextAreaState
(
null
,
'
Hello world!
'
,
0
,
0
,
false
,
0
),
test
DeduceInpu
t
(
new
IENarratorTextAreaState
(
null
,
'
Hello world!
'
,
5
,
5
,
false
,
0
),
'
Hellöö world!
'
,
6
,
6
,
false
,
'
'
5
,
5
,
false
,
'
öö
'
,
1
);
});
test
(
'
extractMacReplacedText - does nothing if there is more than one changed char
'
,
()
=>
{
test
ExtractMacReplacedTex
t
(
new
IENarratorTextAreaState
(
null
,
'
Hello world!
'
,
0
,
0
,
false
,
0
),
test
DeduceInpu
t
(
new
IENarratorTextAreaState
(
null
,
'
Hello world!
'
,
5
,
5
,
false
,
0
),
'
Helöö world!
'
,
6
,
6
,
false
,
'
'
5
,
5
,
false
,
'
öö
'
,
2
);
});
test
(
'
extractMacReplacedText
'
,
()
=>
{
test
ExtractMacReplacedTex
t
(
new
IENarratorTextAreaState
(
null
,
'
Hello world!
'
,
0
,
0
,
false
,
0
),
test
DeduceInpu
t
(
new
IENarratorTextAreaState
(
null
,
'
Hello world!
'
,
5
,
5
,
false
,
0
),
'
Hellö world!
'
,
5
,
5
,
false
,
'
ö
'
'
ö
'
,
1
);
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录