Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
54871729
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,发现更多精彩内容 >>
未验证
提交
54871729
编写于
4月 27, 2020
作者:
J
Johannes Rieken
提交者:
GitHub
4月 27, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #95739 from ChrisPapp/rename_bug_#92507
Prevent unexpected rename cancellation
上级
839ddf9b
384ec8f5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
20 addition
and
15 deletion
+20
-15
src/vs/editor/browser/core/editorState.ts
src/vs/editor/browser/core/editorState.ts
+13
-4
src/vs/editor/contrib/rename/rename.ts
src/vs/editor/contrib/rename/rename.ts
+3
-1
src/vs/editor/contrib/rename/renameInputField.ts
src/vs/editor/contrib/rename/renameInputField.ts
+4
-10
未找到文件。
src/vs/editor/browser/core/editorState.ts
浏览文件 @
54871729
...
...
@@ -6,7 +6,7 @@
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
ICodeEditor
,
IActiveCodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Range
,
IRange
}
from
'
vs/editor/common/core/range
'
;
import
{
CancellationTokenSource
,
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
IDisposable
,
DisposableStore
}
from
'
vs/base/common/lifecycle
'
;
import
{
ITextModel
}
from
'
vs/editor/common/model
'
;
...
...
@@ -87,19 +87,28 @@ export class EditorState {
/**
* A cancellation token source that cancels when the editor changes as expressed
* by the provided flags
* @param range If provided, changes in position and selection within this range will not trigger cancellation
*/
export
class
EditorStateCancellationTokenSource
extends
EditorKeybindingCancellationTokenSource
implements
IDisposable
{
private
readonly
_listener
=
new
DisposableStore
();
constructor
(
readonly
editor
:
IActiveCodeEditor
,
flags
:
CodeEditorStateFlag
,
parent
?:
CancellationToken
)
{
constructor
(
readonly
editor
:
IActiveCodeEditor
,
flags
:
CodeEditorStateFlag
,
parent
?:
CancellationToken
,
readonly
range
?:
IRange
)
{
super
(
editor
,
parent
);
if
(
flags
&
CodeEditorStateFlag
.
Position
)
{
this
.
_listener
.
add
(
editor
.
onDidChangeCursorPosition
(
_
=>
this
.
cancel
()));
this
.
_listener
.
add
(
editor
.
onDidChangeCursorPosition
(
e
=>
{
if
(
!
this
.
range
||
!
Range
.
containsPosition
(
this
.
range
,
e
.
position
))
{
this
.
cancel
();
}
}));
}
if
(
flags
&
CodeEditorStateFlag
.
Selection
)
{
this
.
_listener
.
add
(
editor
.
onDidChangeCursorSelection
(
_
=>
this
.
cancel
()));
this
.
_listener
.
add
(
editor
.
onDidChangeCursorSelection
(
e
=>
{
if
(
!
this
.
range
||
!
Range
.
containsRange
(
this
.
range
,
e
.
selection
))
{
this
.
cancel
();
}
}));
}
if
(
flags
&
CodeEditorStateFlag
.
Scroll
)
{
this
.
_listener
.
add
(
editor
.
onDidScrollChange
(
_
=>
this
.
cancel
()));
...
...
src/vs/editor/contrib/rename/rename.ts
浏览文件 @
54871729
...
...
@@ -168,6 +168,8 @@ class RenameController implements IEditorContribution {
if
(
this
.
_cts
.
token
.
isCancellationRequested
)
{
return
undefined
;
}
this
.
_cts
.
dispose
();
this
.
_cts
=
new
EditorStateCancellationTokenSource
(
this
.
editor
,
CodeEditorStateFlag
.
Position
|
CodeEditorStateFlag
.
Value
,
undefined
,
loc
.
range
);
// do rename at location
let
selection
=
this
.
editor
.
getSelection
();
...
...
@@ -180,7 +182,7 @@ class RenameController implements IEditorContribution {
}
const
supportPreview
=
this
.
_bulkEditService
.
hasPreviewHandler
()
&&
this
.
_configService
.
getValue
<
boolean
>
(
this
.
editor
.
getModel
().
uri
,
'
editor.rename.enablePreview
'
);
const
inputFieldResult
=
await
this
.
_renameInputField
.
getValue
().
getInput
(
loc
.
range
,
loc
.
text
,
selectionStart
,
selectionEnd
,
supportPreview
);
const
inputFieldResult
=
await
this
.
_renameInputField
.
getValue
().
getInput
(
loc
.
range
,
loc
.
text
,
selectionStart
,
selectionEnd
,
supportPreview
,
this
.
_cts
.
token
);
// no result, only hint to focus the editor or not
if
(
typeof
inputFieldResult
===
'
boolean
'
)
{
...
...
src/vs/editor/contrib/rename/renameInputField.ts
浏览文件 @
54871729
...
...
@@ -7,7 +7,7 @@ import 'vs/css!./renameInputField';
import
{
DisposableStore
}
from
'
vs/base/common/lifecycle
'
;
import
{
ContentWidgetPositionPreference
,
ICodeEditor
,
IContentWidget
,
IContentWidgetPosition
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
IRange
,
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
IRange
}
from
'
vs/editor/common/core/range
'
;
import
{
ScrollType
}
from
'
vs/editor/common/editorCommon
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
IContextKey
,
IContextKeyService
,
RawContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
...
...
@@ -16,6 +16,7 @@ import { IColorTheme, IThemeService } from 'vs/platform/theme/common/themeServic
import
{
EditorOption
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
toggleClass
}
from
'
vs/base/browser/dom
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
export
const
CONTEXT_RENAME_INPUT_VISIBLE
=
new
RawContextKey
<
boolean
>
(
'
renameInputVisible
'
,
false
);
...
...
@@ -149,7 +150,7 @@ export class RenameInputField implements IContentWidget {
}
}
getInput
(
where
:
IRange
,
value
:
string
,
selectionStart
:
number
,
selectionEnd
:
number
,
supportPreview
:
boolean
):
Promise
<
RenameInputFieldResult
|
boolean
>
{
getInput
(
where
:
IRange
,
value
:
string
,
selectionStart
:
number
,
selectionEnd
:
number
,
supportPreview
:
boolean
,
token
:
CancellationToken
):
Promise
<
RenameInputFieldResult
|
boolean
>
{
toggleClass
(
this
.
_domNode
!
,
'
preview
'
,
supportPreview
);
...
...
@@ -185,14 +186,7 @@ export class RenameInputField implements IContentWidget {
});
};
let
onCursorChanged
=
()
=>
{
const
editorPosition
=
this
.
_editor
.
getPosition
();
if
(
!
editorPosition
||
!
Range
.
containsPosition
(
where
,
editorPosition
))
{
this
.
cancelInput
(
true
);
}
};
disposeOnDone
.
add
(
this
.
_editor
.
onDidChangeCursorSelection
(
onCursorChanged
));
token
.
onCancellationRequested
(()
=>
this
.
cancelInput
(
true
));
disposeOnDone
.
add
(
this
.
_editor
.
onDidBlurEditorWidget
(()
=>
this
.
cancelInput
(
false
)));
this
.
_show
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录