Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
349c18db
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,发现更多精彩内容 >>
提交
349c18db
编写于
10月 17, 2018
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add CompletionItemInsertTextRules on modes.ts so that we can have that in vscode.d.ts, #57093
上级
cceb2691
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
45 addition
and
19 deletion
+45
-19
src/vs/editor/common/modes.ts
src/vs/editor/common/modes.ts
+16
-4
src/vs/editor/contrib/suggest/suggestController.ts
src/vs/editor/contrib/suggest/suggestController.ts
+5
-5
src/vs/editor/standalone/browser/standaloneLanguages.ts
src/vs/editor/standalone/browser/standaloneLanguages.ts
+1
-0
src/vs/monaco.d.ts
src/vs/monaco.d.ts
+15
-2
src/vs/workbench/api/node/extHostLanguageFeatures.ts
src/vs/workbench/api/node/extHostLanguageFeatures.ts
+4
-4
src/vs/workbench/api/node/extHostTypeConverters.ts
src/vs/workbench/api/node/extHostTypeConverters.ts
+1
-1
src/vs/workbench/parts/snippets/electron-browser/snippetCompletionProvider.ts
...ts/snippets/electron-browser/snippetCompletionProvider.ts
+3
-3
未找到文件。
src/vs/editor/common/modes.ts
浏览文件 @
349c18db
...
...
@@ -357,6 +357,19 @@ export let completionKindFromLegacyString = (function () {
};
})();
export
enum
CompletionItemInsertTextRule
{
/**
* `insertText` is a snippet.
*/
InsertAsSnippet
=
0b01
,
/**
* Adjust whitespace/indentation of multiline insert texts to
* match the current line indentation.
*/
AdjustWhitespace
=
0b10
}
/**
* A completion item represents a text snippet that is
* proposed to complete text that is being typed.
...
...
@@ -407,9 +420,10 @@ export interface CompletionItem {
*/
insertText
:
string
;
/**
* The insert test is a snippet
* Addition rules (as bitmask) that should be applied when inserting
* this completion.
*/
insertText
IsSnippet
?:
boolean
;
insertText
Rules
?:
CompletionItemInsertTextRule
;
/**
* A range of text that should be replaced by this completion item.
*
...
...
@@ -436,8 +450,6 @@ export interface CompletionItem {
* A command that should be run upon acceptance of this item.
*/
command
?:
Command
;
/**@internal*/
noWhitespaceAdjust
?:
boolean
;
/**@internal*/
_labelLow
?:
string
;
...
...
src/vs/editor/contrib/suggest/suggestController.ts
浏览文件 @
349c18db
...
...
@@ -14,7 +14,7 @@ import { EditOperation } from 'vs/editor/common/core/editOperation';
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
IEditorContribution
,
ScrollType
,
Handler
}
from
'
vs/editor/common/editorCommon
'
;
import
{
EditorContextKeys
}
from
'
vs/editor/common/editorContextKeys
'
;
import
{
CompletionItem
,
CompletionItemProvider
}
from
'
vs/editor/common/modes
'
;
import
{
CompletionItem
,
CompletionItemProvider
,
CompletionItemInsertTextRule
}
from
'
vs/editor/common/modes
'
;
import
{
SnippetController2
}
from
'
vs/editor/contrib/snippet/snippetController2
'
;
import
{
SnippetParser
}
from
'
vs/editor/contrib/snippet/snippetParser
'
;
import
{
SuggestMemories
}
from
'
vs/editor/contrib/suggest/suggestMemory
'
;
...
...
@@ -180,7 +180,7 @@ export class SuggestController implements IEditorContribution {
&&
this
.
_model
.
state
===
State
.
Auto
&&
!
item
.
suggestion
.
command
&&
!
item
.
suggestion
.
additionalTextEdits
&&
!
item
.
suggestion
.
insertTextIsSnippet
&&
!
(
item
.
suggestion
.
insertTextRules
&
CompletionItemInsertTextRule
.
InsertAsSnippet
)
&&
endColumn
-
startColumn
===
item
.
suggestion
.
insertText
.
length
)
{
const
oldText
=
this
.
_editor
.
getModel
().
getValueInRange
({
...
...
@@ -239,7 +239,7 @@ export class SuggestController implements IEditorContribution {
this
.
_memory
.
getValue
().
memorize
(
this
.
_editor
.
getModel
(),
this
.
_editor
.
getPosition
(),
event
.
item
);
let
{
insertText
}
=
suggestion
;
if
(
!
suggestion
.
insertTextIsSnippet
)
{
if
(
!
(
suggestion
.
insertTextRules
&
CompletionItemInsertTextRule
.
InsertAsSnippet
)
)
{
insertText
=
SnippetParser
.
escape
(
insertText
);
}
...
...
@@ -251,7 +251,7 @@ export class SuggestController implements IEditorContribution {
overwriteBefore
+
columnDelta
,
overwriteAfter
,
false
,
false
,
!
suggestion
.
noWhitespaceAdjust
Boolean
(
suggestion
.
insertTextRules
&
CompletionItemInsertTextRule
.
AdjustWhitespace
)
);
if
(
undoStops
)
{
...
...
@@ -315,7 +315,7 @@ export class SuggestController implements IEditorContribution {
};
const
makesTextEdit
=
(
item
:
ISuggestionItem
):
boolean
=>
{
if
(
item
.
suggestion
.
insertText
I
sSnippet
||
item
.
suggestion
.
additionalTextEdits
)
{
if
(
item
.
suggestion
.
insertText
Rules
&
CompletionItemInsertTextRule
.
InsertA
sSnippet
||
item
.
suggestion
.
additionalTextEdits
)
{
// snippet, other editor -> makes edit
return
true
;
}
...
...
src/vs/editor/standalone/browser/standaloneLanguages.ts
浏览文件 @
349c18db
...
...
@@ -534,6 +534,7 @@ export function createMonacoLanguagesAPI(): typeof monaco.languages {
// enums
DocumentHighlightKind
:
modes
.
DocumentHighlightKind
,
CompletionItemKind
:
modes
.
CompletionItemKind
,
CompletionItemInsertTextRule
:
modes
.
CompletionItemInsertTextRule
,
SymbolKind
:
modes
.
SymbolKind
,
IndentAction
:
IndentAction
,
CompletionTriggerKind
:
modes
.
CompletionTriggerKind
,
...
...
src/vs/monaco.d.ts
浏览文件 @
349c18db
...
...
@@ -4700,6 +4700,18 @@ declare namespace monaco.languages {
Snippet
=
25
}
export
enum
CompletionItemInsertTextRule
{
/**
* `insertText` is a snippet.
*/
InsertAsSnippet
=
1
,
/**
* Adjust whitespace/indentation of multiline insert texts to
* match the current line indentation.
*/
AdjustWhitespace
=
2
}
/**
* A completion item represents a text snippet that is
* proposed to complete text that is being typed.
...
...
@@ -4750,9 +4762,10 @@ declare namespace monaco.languages {
*/
insertText
:
string
;
/**
* The insert test is a snippet
* Addition rules (as bitmask) that should be applied when inserting
* this completion.
*/
insertText
IsSnippet
?:
boolean
;
insertText
Rules
?:
CompletionItemInsertTextRule
;
/**
* A range of text that should be replaced by this completion item.
*
...
...
src/vs/workbench/api/node/extHostLanguageFeatures.ts
浏览文件 @
349c18db
...
...
@@ -683,19 +683,19 @@ class SuggestAdapter {
// 'insertText'-logic
if
(
item
.
textEdit
)
{
result
.
insertText
=
item
.
textEdit
.
newText
;
result
.
insertText
IsSnippet
=
fals
e
;
result
.
insertText
Rules
=
modes
.
CompletionItemInsertTextRule
.
AdjustWhitespac
e
;
}
else
if
(
typeof
item
.
insertText
===
'
string
'
)
{
result
.
insertText
=
item
.
insertText
;
result
.
insertText
IsSnippet
=
fals
e
;
result
.
insertText
Rules
=
modes
.
CompletionItemInsertTextRule
.
AdjustWhitespac
e
;
}
else
if
(
item
.
insertText
instanceof
SnippetString
)
{
result
.
insertText
=
item
.
insertText
.
value
;
result
.
insertText
IsSnippet
=
true
;
result
.
insertText
Rules
=
modes
.
CompletionItemInsertTextRule
.
AdjustWhitespace
|
modes
.
CompletionItemInsertTextRule
.
InsertAsSnippet
;
}
else
{
result
.
insertText
=
item
.
label
;
result
.
insertText
IsSnippet
=
fals
e
;
result
.
insertText
Rules
=
modes
.
CompletionItemInsertTextRule
.
AdjustWhitespac
e
;
}
// 'overwrite[Before|After]'-logic
...
...
src/vs/workbench/api/node/extHostTypeConverters.ts
浏览文件 @
349c18db
...
...
@@ -556,7 +556,7 @@ export namespace Suggest {
result
.
range
=
Range
.
to
(
suggestion
.
range
);
// 'inserText'-logic
if
(
suggestion
.
insertText
I
sSnippet
)
{
if
(
suggestion
.
insertText
Rules
&
modes
.
CompletionItemInsertTextRule
.
InsertA
sSnippet
)
{
result
.
insertText
=
new
types
.
SnippetString
(
suggestion
.
insertText
);
}
else
{
result
.
insertText
=
suggestion
.
insertText
;
...
...
src/vs/workbench/parts/snippets/electron-browser/snippetCompletionProvider.ts
浏览文件 @
349c18db
...
...
@@ -10,7 +10,7 @@ import { compare } from 'vs/base/common/strings';
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
IRange
,
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
CompletionItem
,
CompletionItemKind
,
CompletionItemProvider
,
CompletionList
,
LanguageId
}
from
'
vs/editor/common/modes
'
;
import
{
CompletionItem
,
CompletionItemKind
,
CompletionItemProvider
,
CompletionList
,
LanguageId
,
CompletionItemInsertTextRule
}
from
'
vs/editor/common/modes
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
SnippetParser
}
from
'
vs/editor/contrib/snippet/snippetParser
'
;
import
{
localize
}
from
'
vs/nls
'
;
...
...
@@ -26,7 +26,7 @@ export class SnippetCompletion implements CompletionItem {
range
:
IRange
;
sortText
:
string
;
kind
:
CompletionItemKind
;
insertText
IsSnippet
:
tru
e
;
insertText
Rules
:
CompletionItemInsertTextRul
e
;
constructor
(
readonly
snippet
:
Snippet
,
...
...
@@ -38,7 +38,7 @@ export class SnippetCompletion implements CompletionItem {
this
.
range
=
range
;
this
.
sortText
=
`
${
snippet
.
snippetSource
===
SnippetSource
.
Extension
?
'
z
'
:
'
a
'
}
-
${
snippet
.
prefix
}
`
;
this
.
kind
=
CompletionItemKind
.
Snippet
;
this
.
insertText
IsSnippet
=
tru
e
;
this
.
insertText
Rules
=
CompletionItemInsertTextRule
.
InsertAsSnippet
|
CompletionItemInsertTextRule
.
AdjustWhitespac
e
;
}
resolve
():
this
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录