Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
888f7449
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,发现更多精彩内容 >>
提交
888f7449
编写于
1月 26, 2018
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
lineWarningLength -> validationProvider
上级
786ea020
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
219 addition
and
71 deletion
+219
-71
extensions/git/package.json
extensions/git/package.json
+10
-0
extensions/git/package.nls.json
extensions/git/package.nls.json
+1
-0
extensions/git/src/repository.ts
extensions/git/src/repository.ts
+41
-2
src/vs/vscode.d.ts
src/vs/vscode.d.ts
+53
-2
src/vs/workbench/api/electron-browser/mainThreadSCM.ts
src/vs/workbench/api/electron-browser/mainThreadSCM.ts
+18
-3
src/vs/workbench/api/node/extHost.api.impl.ts
src/vs/workbench/api/node/extHost.api.impl.ts
+1
-0
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+2
-1
src/vs/workbench/api/node/extHostSCM.ts
src/vs/workbench/api/node/extHostSCM.ts
+29
-6
src/vs/workbench/api/node/extHostTypes.ts
src/vs/workbench/api/node/extHostTypes.ts
+6
-0
src/vs/workbench/parts/scm/electron-browser/scm.contribution.ts
.../workbench/parts/scm/electron-browser/scm.contribution.ts
+0
-6
src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts
src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts
+26
-48
src/vs/workbench/services/scm/common/scm.ts
src/vs/workbench/services/scm/common/scm.ts
+17
-1
src/vs/workbench/services/scm/common/scmService.ts
src/vs/workbench/services/scm/common/scmService.ts
+15
-2
未找到文件。
extensions/git/package.json
浏览文件 @
888f7449
...
@@ -946,6 +946,16 @@
...
@@ -946,6 +946,16 @@
"type"
:
"boolean"
,
"type"
:
"boolean"
,
"default"
:
true
,
"default"
:
true
,
"description"
:
"%config.showInlineOpenFileAction%"
"description"
:
"%config.showInlineOpenFileAction%"
},
"git.inputValidation"
:
{
"type"
:
"string"
,
"enum"
:
[
"always"
,
"warn"
,
"off"
],
"default"
:
"warn"
,
"description"
:
"%config.inputValidation%"
}
}
}
}
},
},
...
...
extensions/git/package.nls.json
浏览文件 @
888f7449
...
@@ -66,6 +66,7 @@
...
@@ -66,6 +66,7 @@
"config.decorations.enabled"
:
"Controls if Git contributes colors and badges to the explorer and the open editors view."
,
"config.decorations.enabled"
:
"Controls if Git contributes colors and badges to the explorer and the open editors view."
,
"config.promptToSaveFilesBeforeCommit"
:
"Controls whether Git should check for unsaved files before committing."
,
"config.promptToSaveFilesBeforeCommit"
:
"Controls whether Git should check for unsaved files before committing."
,
"config.showInlineOpenFileAction"
:
"Controls whether to show an inline Open File action in the Git changes view."
,
"config.showInlineOpenFileAction"
:
"Controls whether to show an inline Open File action in the Git changes view."
,
"config.inputValidation"
:
"Controls when to show input validation the input counter."
,
"colors.modified"
:
"Color for modified resources."
,
"colors.modified"
:
"Color for modified resources."
,
"colors.deleted"
:
"Color for deleted resources."
,
"colors.deleted"
:
"Color for deleted resources."
,
"colors.untracked"
:
"Color for untracked resources."
,
"colors.untracked"
:
"Color for untracked resources."
,
...
...
extensions/git/src/repository.ts
浏览文件 @
888f7449
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
'
use strict
'
;
'
use strict
'
;
import
{
Uri
,
Command
,
EventEmitter
,
Event
,
scm
,
SourceControl
,
SourceControlInputBox
,
SourceControlResourceGroup
,
SourceControlResourceState
,
SourceControlResourceDecorations
,
Disposable
,
ProgressLocation
,
window
,
workspace
,
WorkspaceEdit
,
ThemeColor
,
DecorationData
,
Memento
}
from
'
vscode
'
;
import
{
Uri
,
Command
,
EventEmitter
,
Event
,
scm
,
SourceControl
,
SourceControlInputBox
,
SourceControlResourceGroup
,
SourceControlResourceState
,
SourceControlResourceDecorations
,
SourceControlInputBoxValidation
,
Disposable
,
ProgressLocation
,
window
,
workspace
,
WorkspaceEdit
,
ThemeColor
,
DecorationData
,
Memento
,
SourceControlInputBoxValidationType
}
from
'
vscode
'
;
import
{
Repository
as
BaseRepository
,
Ref
,
Branch
,
Remote
,
Commit
,
GitErrorCodes
,
Stash
,
RefType
,
GitError
,
Submodule
,
DiffOptions
}
from
'
./git
'
;
import
{
Repository
as
BaseRepository
,
Ref
,
Branch
,
Remote
,
Commit
,
GitErrorCodes
,
Stash
,
RefType
,
GitError
,
Submodule
,
DiffOptions
}
from
'
./git
'
;
import
{
anyEvent
,
filterEvent
,
eventToPromise
,
dispose
,
find
,
isDescendant
,
IDisposable
,
onceEvent
,
EmptyDisposable
,
debounceEvent
}
from
'
./util
'
;
import
{
anyEvent
,
filterEvent
,
eventToPromise
,
dispose
,
find
,
isDescendant
,
IDisposable
,
onceEvent
,
EmptyDisposable
,
debounceEvent
}
from
'
./util
'
;
import
{
memoize
,
throttle
,
debounce
}
from
'
./decorators
'
;
import
{
memoize
,
throttle
,
debounce
}
from
'
./decorators
'
;
...
@@ -419,6 +419,8 @@ class ProgressManager {
...
@@ -419,6 +419,8 @@ class ProgressManager {
export
class
Repository
implements
Disposable
{
export
class
Repository
implements
Disposable
{
private
static
readonly
InputValidationLength
=
72
;
private
_onDidChangeRepository
=
new
EventEmitter
<
Uri
>
();
private
_onDidChangeRepository
=
new
EventEmitter
<
Uri
>
();
readonly
onDidChangeRepository
:
Event
<
Uri
>
=
this
.
_onDidChangeRepository
.
event
;
readonly
onDidChangeRepository
:
Event
<
Uri
>
=
this
.
_onDidChangeRepository
.
event
;
...
@@ -521,7 +523,7 @@ export class Repository implements Disposable {
...
@@ -521,7 +523,7 @@ export class Repository implements Disposable {
this
.
_sourceControl
.
inputBox
.
placeholder
=
localize
(
'
commitMessage
'
,
"
Message (press {0} to commit)
"
);
this
.
_sourceControl
.
inputBox
.
placeholder
=
localize
(
'
commitMessage
'
,
"
Message (press {0} to commit)
"
);
this
.
_sourceControl
.
acceptInputCommand
=
{
command
:
'
git.commitWithInput
'
,
title
:
localize
(
'
commit
'
,
"
Commit
"
),
arguments
:
[
this
.
_sourceControl
]
};
this
.
_sourceControl
.
acceptInputCommand
=
{
command
:
'
git.commitWithInput
'
,
title
:
localize
(
'
commit
'
,
"
Commit
"
),
arguments
:
[
this
.
_sourceControl
]
};
this
.
_sourceControl
.
quickDiffProvider
=
this
;
this
.
_sourceControl
.
quickDiffProvider
=
this
;
this
.
_sourceControl
.
inputBox
.
lineWarningLength
=
72
;
this
.
_sourceControl
.
inputBox
.
validationProvider
=
this
;
this
.
disposables
.
push
(
this
.
_sourceControl
);
this
.
disposables
.
push
(
this
.
_sourceControl
);
this
.
_mergeGroup
=
this
.
_sourceControl
.
createResourceGroup
(
'
merge
'
,
localize
(
'
merge changes
'
,
"
Merge Changes
"
));
this
.
_mergeGroup
=
this
.
_sourceControl
.
createResourceGroup
(
'
merge
'
,
localize
(
'
merge changes
'
,
"
Merge Changes
"
));
...
@@ -549,6 +551,43 @@ export class Repository implements Disposable {
...
@@ -549,6 +551,43 @@ export class Repository implements Disposable {
this
.
status
();
this
.
status
();
}
}
validateInput
(
text
:
string
,
position
:
number
):
SourceControlInputBoxValidation
|
undefined
{
const
config
=
workspace
.
getConfiguration
(
'
git
'
);
const
setting
=
config
.
get
<
'
always
'
|
'
warn
'
|
'
off
'
>
(
'
inputValidation
'
);
if
(
setting
===
'
off
'
)
{
return
;
}
let
start
=
0
,
end
;
let
match
:
RegExpExecArray
|
null
;
const
regex
=
/
\r?\n
/g
;
while
((
match
=
regex
.
exec
(
text
))
&&
position
>
match
.
index
)
{
start
=
match
.
index
+
match
[
0
].
length
;
}
end
=
match
?
match
.
index
:
text
.
length
;
const
line
=
text
.
substring
(
start
,
end
);
if
(
line
.
length
<=
Repository
.
InputValidationLength
)
{
if
(
setting
!==
'
always
'
)
{
return
;
}
return
{
message
:
localize
(
'
commitMessageCountdown
'
,
"
{0} characters left in current line
"
,
Repository
.
InputValidationLength
-
line
.
length
),
type
:
SourceControlInputBoxValidationType
.
Information
};
}
else
{
return
{
message
:
localize
(
'
commitMessageWarning
'
,
"
{0} characters over {1} in current line
"
,
line
.
length
-
Repository
.
InputValidationLength
,
Repository
.
InputValidationLength
),
type
:
SourceControlInputBoxValidationType
.
Warning
};
}
}
provideOriginalResource
(
uri
:
Uri
):
Uri
|
undefined
{
provideOriginalResource
(
uri
:
Uri
):
Uri
|
undefined
{
if
(
uri
.
scheme
!==
'
file
'
)
{
if
(
uri
.
scheme
!==
'
file
'
)
{
return
;
return
;
...
...
src/vs/vscode.d.ts
浏览文件 @
888f7449
...
@@ -5986,6 +5986,56 @@ declare module 'vscode' {
...
@@ -5986,6 +5986,56 @@ declare module 'vscode' {
export
function
setLanguageConfiguration
(
language
:
string
,
configuration
:
LanguageConfiguration
):
Disposable
;
export
function
setLanguageConfiguration
(
language
:
string
,
configuration
:
LanguageConfiguration
):
Disposable
;
}
}
/**
* Represents the validation type of the Source Control input.
*/
export
enum
SourceControlInputBoxValidationType
{
/**
* Something not allowed by the rules of a language or other means.
*/
Error
=
0
,
/**
* Something suspicious but allowed.
*/
Warning
=
1
,
/**
* Something to inform about but not a problem.
*/
Information
=
2
}
export
interface
SourceControlInputBoxValidation
{
/**
* The validation message to display.
*/
readonly
message
:
string
;
/**
* The validation type.
*/
readonly
type
:
SourceControlInputBoxValidationType
;
}
/**
* A validation provider which can validate Source Control input.
*/
export
interface
SourceControlInputBoxValidationProvider
{
/**
* A function that will be called to validate input and give a hint to the user.
*
* @param value The current value of the input box.
* @param cursorPosition The cusror position within the input box.
* @return A human readable string which is presented as diagnostic message.
* Return `undefined`, `null`, or the empty string when 'value' is valid.
*/
validateInput
(
value
:
string
,
cursorPosition
:
number
):
ProviderResult
<
SourceControlInputBoxValidation
|
undefined
|
null
>
;
}
/**
/**
* Represents the input box in the Source Control viewlet.
* Represents the input box in the Source Control viewlet.
*/
*/
...
@@ -6002,9 +6052,10 @@ declare module 'vscode' {
...
@@ -6002,9 +6052,10 @@ declare module 'vscode' {
placeholder
:
string
;
placeholder
:
string
;
/**
/**
* The warning threshold for lines in the input box.
* A validation provider for the input box. It's possible to change
* the validation provider simply by setting this property to a different value.
*/
*/
lineWarningLength
:
number
|
undefined
;
validationProvider
:
SourceControlInputBoxValidationProvider
;
}
}
interface
QuickDiffProvider
{
interface
QuickDiffProvider
{
...
...
src/vs/workbench/api/electron-browser/mainThreadSCM.ts
浏览文件 @
888f7449
...
@@ -10,7 +10,7 @@ import URI from 'vs/base/common/uri';
...
@@ -10,7 +10,7 @@ import URI from 'vs/base/common/uri';
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
assign
}
from
'
vs/base/common/objects
'
;
import
{
assign
}
from
'
vs/base/common/objects
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
ISCMService
,
ISCMRepository
,
ISCMProvider
,
ISCMResource
,
ISCMResourceGroup
,
ISCMResourceDecorations
}
from
'
vs/workbench/services/scm/common/scm
'
;
import
{
ISCMService
,
ISCMRepository
,
ISCMProvider
,
ISCMResource
,
ISCMResourceGroup
,
ISCMResourceDecorations
,
IInputValidation
}
from
'
vs/workbench/services/scm/common/scm
'
;
import
{
ExtHostContext
,
MainThreadSCMShape
,
ExtHostSCMShape
,
SCMProviderFeatures
,
SCMRawResourceSplices
,
SCMGroupFeatures
,
MainContext
,
IExtHostContext
}
from
'
../node/extHost.protocol
'
;
import
{
ExtHostContext
,
MainThreadSCMShape
,
ExtHostSCMShape
,
SCMProviderFeatures
,
SCMRawResourceSplices
,
SCMGroupFeatures
,
MainContext
,
IExtHostContext
}
from
'
../node/extHost.protocol
'
;
import
{
Command
}
from
'
vs/editor/common/modes
'
;
import
{
Command
}
from
'
vs/editor/common/modes
'
;
import
{
extHostNamedCustomer
}
from
'
vs/workbench/api/electron-browser/extHostCustomers
'
;
import
{
extHostNamedCustomer
}
from
'
vs/workbench/api/electron-browser/extHostCustomers
'
;
...
@@ -393,13 +393,28 @@ export class MainThreadSCM implements MainThreadSCMShape {
...
@@ -393,13 +393,28 @@ export class MainThreadSCM implements MainThreadSCMShape {
repository
.
input
.
placeholder
=
placeholder
;
repository
.
input
.
placeholder
=
placeholder
;
}
}
$set
LineWarningLength
(
sourceControlHandle
:
number
,
lineWarningLength
:
number
):
void
{
$set
ValidationProviderIsEnabled
(
sourceControlHandle
:
number
,
enabled
:
boolean
):
void
{
const
repository
=
this
.
_repositories
[
sourceControlHandle
];
const
repository
=
this
.
_repositories
[
sourceControlHandle
];
if
(
!
repository
)
{
if
(
!
repository
)
{
return
;
return
;
}
}
repository
.
input
.
lineWarningLength
=
lineWarningLength
;
if
(
enabled
)
{
repository
.
input
.
validateInput
=
async
(
value
,
pos
):
TPromise
<
IInputValidation
|
undefined
>
=>
{
const
result
=
await
this
.
_proxy
.
$validateInput
(
sourceControlHandle
,
value
,
pos
);
if
(
!
result
)
{
return
undefined
;
}
return
{
message
:
result
[
0
],
type
:
result
[
1
]
};
};
}
else
{
repository
.
input
.
validateInput
=
()
=>
TPromise
.
as
(
undefined
);
}
}
}
}
}
src/vs/workbench/api/node/extHost.api.impl.ts
浏览文件 @
888f7449
...
@@ -601,6 +601,7 @@ export function createApiFactory(
...
@@ -601,6 +601,7 @@ export function createApiFactory(
StatusBarAlignment
:
extHostTypes
.
StatusBarAlignment
,
StatusBarAlignment
:
extHostTypes
.
StatusBarAlignment
,
SymbolInformation
:
extHostTypes
.
SymbolInformation
,
SymbolInformation
:
extHostTypes
.
SymbolInformation
,
SymbolKind
:
extHostTypes
.
SymbolKind
,
SymbolKind
:
extHostTypes
.
SymbolKind
,
SourceControlInputBoxValidationType
:
extHostTypes
.
SourceControlInputBoxValidationType
,
TextDocumentSaveReason
:
extHostTypes
.
TextDocumentSaveReason
,
TextDocumentSaveReason
:
extHostTypes
.
TextDocumentSaveReason
,
TextEdit
:
extHostTypes
.
TextEdit
,
TextEdit
:
extHostTypes
.
TextEdit
,
TextEditorCursorStyle
:
TextEditorCursorStyle
,
TextEditorCursorStyle
:
TextEditorCursorStyle
,
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
888f7449
...
@@ -431,7 +431,7 @@ export interface MainThreadSCMShape extends IDisposable {
...
@@ -431,7 +431,7 @@ export interface MainThreadSCMShape extends IDisposable {
$setInputBoxValue
(
sourceControlHandle
:
number
,
value
:
string
):
void
;
$setInputBoxValue
(
sourceControlHandle
:
number
,
value
:
string
):
void
;
$setInputBoxPlaceholder
(
sourceControlHandle
:
number
,
placeholder
:
string
):
void
;
$setInputBoxPlaceholder
(
sourceControlHandle
:
number
,
placeholder
:
string
):
void
;
$set
LineWarningLength
(
sourceControlHandle
:
number
,
lineWarningLength
:
number
):
void
;
$set
ValidationProviderIsEnabled
(
sourceControlHandle
:
number
,
enabled
:
boolean
):
void
;
}
}
export
type
DebugSessionUUID
=
string
;
export
type
DebugSessionUUID
=
string
;
...
@@ -693,6 +693,7 @@ export interface ExtHostSCMShape {
...
@@ -693,6 +693,7 @@ export interface ExtHostSCMShape {
$provideOriginalResource
(
sourceControlHandle
:
number
,
uri
:
string
):
TPromise
<
string
>
;
$provideOriginalResource
(
sourceControlHandle
:
number
,
uri
:
string
):
TPromise
<
string
>
;
$onInputBoxValueChange
(
sourceControlHandle
:
number
,
value
:
string
):
TPromise
<
void
>
;
$onInputBoxValueChange
(
sourceControlHandle
:
number
,
value
:
string
):
TPromise
<
void
>
;
$executeResourceCommand
(
sourceControlHandle
:
number
,
groupHandle
:
number
,
handle
:
number
):
TPromise
<
void
>
;
$executeResourceCommand
(
sourceControlHandle
:
number
,
groupHandle
:
number
,
handle
:
number
):
TPromise
<
void
>
;
$validateInput
(
sourceControlHandle
:
number
,
value
:
string
,
cursorPosition
:
number
):
TPromise
<
[
string
,
number
]
|
undefined
>
;
}
}
export
interface
ExtHostTaskShape
{
export
interface
ExtHostTaskShape
{
...
...
src/vs/workbench/api/node/extHostSCM.ts
浏览文件 @
888f7449
...
@@ -140,15 +140,20 @@ export class ExtHostSCMInputBox implements vscode.SourceControlInputBox {
...
@@ -140,15 +140,20 @@ export class ExtHostSCMInputBox implements vscode.SourceControlInputBox {
this
.
_placeholder
=
placeholder
;
this
.
_placeholder
=
placeholder
;
}
}
private
_
lineWarningLength
:
number
|
undefined
;
private
_
validationProvider
:
vscode
.
SourceControlInputBoxValidationProvider
;
get
lineWarningLength
():
number
|
undefined
{
get
validationProvider
():
vscode
.
SourceControlInputBoxValidationProvider
{
return
this
.
_
lineWarningLength
;
return
this
.
_
validationProvider
;
}
}
set
lineWarningLength
(
lineWarningLength
:
number
)
{
set
validationProvider
(
provider
:
vscode
.
SourceControlInputBoxValidationProvider
)
{
this
.
_proxy
.
$setLineWarningLength
(
this
.
_sourceControlHandle
,
lineWarningLength
);
if
(
!
provider
||
typeof
provider
.
validateInput
!==
'
function
'
)
{
this
.
_lineWarningLength
=
lineWarningLength
;
console
.
warn
(
'
INVALID SCM input box validation provider
'
);
return
;
}
this
.
_validationProvider
=
provider
;
this
.
_proxy
.
$setValidationProviderIsEnabled
(
this
.
_sourceControlHandle
,
true
);
}
}
constructor
(
private
_proxy
:
MainThreadSCMShape
,
private
_sourceControlHandle
:
number
)
{
constructor
(
private
_proxy
:
MainThreadSCMShape
,
private
_sourceControlHandle
:
number
)
{
...
@@ -567,4 +572,22 @@ export class ExtHostSCM implements ExtHostSCMShape {
...
@@ -567,4 +572,22 @@ export class ExtHostSCM implements ExtHostSCMShape {
await
group
.
$executeResourceCommand
(
handle
);
await
group
.
$executeResourceCommand
(
handle
);
}
}
async
$validateInput
(
sourceControlHandle
:
number
,
value
:
string
,
cursorPosition
:
number
):
TPromise
<
[
string
,
number
]
|
undefined
>
{
this
.
logService
.
trace
(
'
ExtHostSCM#$validateInput
'
,
sourceControlHandle
);
const
sourceControl
=
this
.
_sourceControls
.
get
(
sourceControlHandle
);
if
(
!
sourceControl
)
{
return
TPromise
.
as
(
undefined
);
}
const
result
=
await
sourceControl
.
inputBox
.
validationProvider
.
validateInput
(
value
,
cursorPosition
);
if
(
!
result
)
{
return
TPromise
.
as
(
undefined
);
}
return
[
result
.
message
,
result
.
type
];
}
}
}
src/vs/workbench/api/node/extHostTypes.ts
浏览文件 @
888f7449
...
@@ -1200,6 +1200,12 @@ export enum ColorFormat {
...
@@ -1200,6 +1200,12 @@ export enum ColorFormat {
HSL
=
2
HSL
=
2
}
}
export
enum
SourceControlInputBoxValidationType
{
Error
=
0
,
Warning
=
1
,
Information
=
2
}
export
enum
TaskRevealKind
{
export
enum
TaskRevealKind
{
Always
=
1
,
Always
=
1
,
...
...
src/vs/workbench/parts/scm/electron-browser/scm.contribution.ts
浏览文件 @
888f7449
...
@@ -79,12 +79,6 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).regis
...
@@ -79,12 +79,6 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).regis
enum
:
[
'
all
'
,
'
gutter
'
,
'
overview
'
,
'
none
'
],
enum
:
[
'
all
'
,
'
gutter
'
,
'
overview
'
,
'
none
'
],
default
:
'
all
'
,
default
:
'
all
'
,
description
:
localize
(
'
diffDecorations
'
,
"
Controls diff decorations in the editor.
"
)
description
:
localize
(
'
diffDecorations
'
,
"
Controls diff decorations in the editor.
"
)
},
'
scm.inputCounter
'
:
{
type
:
'
string
'
,
enum
:
[
'
always
'
,
'
warn
'
,
'
off
'
],
default
:
'
warn
'
,
description
:
localize
(
'
inputCounter
'
,
"
Controls when to display the input counter.
"
)
}
}
}
}
});
});
\ No newline at end of file
src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts
浏览文件 @
888f7449
...
@@ -22,7 +22,7 @@ import { IDelegate, IRenderer, IListContextMenuEvent, IListEvent } from 'vs/base
...
@@ -22,7 +22,7 @@ import { IDelegate, IRenderer, IListContextMenuEvent, IListEvent } from 'vs/base
import
{
VIEWLET_ID
}
from
'
vs/workbench/parts/scm/common/scm
'
;
import
{
VIEWLET_ID
}
from
'
vs/workbench/parts/scm/common/scm
'
;
import
{
FileLabel
}
from
'
vs/workbench/browser/labels
'
;
import
{
FileLabel
}
from
'
vs/workbench/browser/labels
'
;
import
{
CountBadge
}
from
'
vs/base/browser/ui/countBadge/countBadge
'
;
import
{
CountBadge
}
from
'
vs/base/browser/ui/countBadge/countBadge
'
;
import
{
ISCMService
,
ISCMRepository
,
ISCMResourceGroup
,
ISCMResource
}
from
'
vs/workbench/services/scm/common/scm
'
;
import
{
ISCMService
,
ISCMRepository
,
ISCMResourceGroup
,
ISCMResource
,
InputValidationType
}
from
'
vs/workbench/services/scm/common/scm
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
...
@@ -45,7 +45,7 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace
...
@@ -45,7 +45,7 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
IViewletService
}
from
'
vs/workbench/services/viewlet/browser/viewlet
'
;
import
{
IViewletService
}
from
'
vs/workbench/services/viewlet/browser/viewlet
'
;
import
{
IExtensionsViewlet
,
VIEWLET_ID
as
EXTENSIONS_VIEWLET_ID
}
from
'
vs/workbench/parts/extensions/common/extensions
'
;
import
{
IExtensionsViewlet
,
VIEWLET_ID
as
EXTENSIONS_VIEWLET_ID
}
from
'
vs/workbench/parts/extensions/common/extensions
'
;
import
{
I
Message
,
I
nputBox
,
MessageType
}
from
'
vs/base/browser/ui/inputbox/inputBox
'
;
import
{
InputBox
,
MessageType
}
from
'
vs/base/browser/ui/inputbox/inputBox
'
;
import
{
StandardKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
StandardKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
KeyMod
,
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
KeyMod
,
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
Command
}
from
'
vs/editor/common/modes
'
;
import
{
Command
}
from
'
vs/editor/common/modes
'
;
...
@@ -57,6 +57,7 @@ import { ISpliceable, ISequence, ISplice } from 'vs/base/common/sequence';
...
@@ -57,6 +57,7 @@ import { ISpliceable, ISequence, ISplice } from 'vs/base/common/sequence';
import
{
firstIndex
}
from
'
vs/base/common/arrays
'
;
import
{
firstIndex
}
from
'
vs/base/common/arrays
'
;
import
{
WorkbenchList
}
from
'
vs/platform/list/browser/listService
'
;
import
{
WorkbenchList
}
from
'
vs/platform/list/browser/listService
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
ThrottledDelayer
}
from
'
vs/base/common/async
'
;
// TODO@Joao
// TODO@Joao
// Need to subclass MenuItemActionItem in order to respect
// Need to subclass MenuItemActionItem in order to respect
...
@@ -684,6 +685,14 @@ class ResourceGroupSplicer {
...
@@ -684,6 +685,14 @@ class ResourceGroupSplicer {
}
}
}
}
function
convertValidationType
(
type
:
InputValidationType
):
MessageType
{
switch
(
type
)
{
case
InputValidationType
.
Information
:
return
MessageType
.
INFO
;
case
InputValidationType
.
Warning
:
return
MessageType
.
WARNING
;
case
InputValidationType
.
Error
:
return
MessageType
.
ERROR
;
}
}
export
class
RepositoryPanel
extends
ViewletPanel
{
export
class
RepositoryPanel
extends
ViewletPanel
{
private
cachedHeight
:
number
|
undefined
=
undefined
;
private
cachedHeight
:
number
|
undefined
=
undefined
;
...
@@ -764,62 +773,31 @@ export class RepositoryPanel extends ViewletPanel {
...
@@ -764,62 +773,31 @@ export class RepositoryPanel extends ViewletPanel {
this
.
inputBox
.
setPlaceHolder
(
placeholder
);
this
.
inputBox
.
setPlaceHolder
(
placeholder
);
};
};
const
validation
=
(
text
:
string
):
IMessage
=>
{
const
validationDelayer
=
new
ThrottledDelayer
(
200
);
const
setting
=
this
.
configurationService
.
getValue
<
'
always
'
|
'
warn
'
|
'
off
'
>
(
'
scm.inputCounter
'
);
if
(
setting
===
'
off
'
)
{
return
null
;
}
let
position
=
this
.
inputBox
.
inputElement
.
selectionStart
;
let
start
=
0
,
end
;
let
match
:
RegExpExecArray
;
const
regex
=
/
\r?\n
/g
;
while
((
match
=
regex
.
exec
(
text
))
&&
position
>
match
.
index
)
{
start
=
match
.
index
+
match
[
0
].
length
;
}
end
=
match
?
match
.
index
:
text
.
length
;
const
line
=
text
.
substring
(
start
,
end
);
const
validate
=
()
=>
{
validationDelayer
.
trigger
(
async
():
TPromise
<
any
>
=>
{
const
result
=
await
this
.
repository
.
input
.
validateInput
(
this
.
inputBox
.
value
,
this
.
inputBox
.
inputElement
.
selectionStart
);
const
lineWarningLength
=
this
.
repository
.
input
.
lineWarningLength
;
if
(
!
result
)
{
this
.
inputBox
.
inputElement
.
removeAttribute
(
'
aria-invalid
'
);
if
(
lineWarningLength
===
undefined
)
{
this
.
inputBox
.
hideMessage
();
return
{
}
else
{
content
:
localize
(
'
commitMessageInfo
'
,
"
{0} characters in current line
"
,
text
.
length
),
this
.
inputBox
.
inputElement
.
setAttribute
(
'
aria-invalid
'
,
'
true
'
);
type
:
MessageType
.
INFO
this
.
inputBox
.
showMessage
({
content
:
result
.
message
,
type
:
convertValidationType
(
result
.
type
)
});
};
}
if
(
line
.
length
<=
lineWarningLength
)
{
if
(
setting
!==
'
always
'
)
{
return
null
;
}
}
});
return
{
content
:
localize
(
'
commitMessageCountdown
'
,
"
{0} characters left in current line
"
,
lineWarningLength
-
line
.
length
),
type
:
MessageType
.
INFO
};
}
else
{
return
{
content
:
localize
(
'
commitMessageWarning
'
,
"
{0} characters over {1} in current line
"
,
line
.
length
-
lineWarningLength
,
lineWarningLength
),
type
:
MessageType
.
WARNING
};
}
};
};
this
.
inputBox
=
new
InputBox
(
this
.
inputBoxContainer
,
this
.
contextViewService
,
{
this
.
inputBox
=
new
InputBox
(
this
.
inputBoxContainer
,
this
.
contextViewService
,
{
flexibleHeight
:
true
});
flexibleHeight
:
true
,
validationOptions
:
{
validation
:
validation
}
});
this
.
disposables
.
push
(
attachInputBoxStyler
(
this
.
inputBox
,
this
.
themeService
));
this
.
disposables
.
push
(
attachInputBoxStyler
(
this
.
inputBox
,
this
.
themeService
));
this
.
disposables
.
push
(
this
.
inputBox
);
this
.
disposables
.
push
(
this
.
inputBox
);
this
.
inputBox
.
onDidChange
(
validate
,
null
,
this
.
disposables
);
const
onKeyUp
=
domEvent
(
this
.
inputBox
.
inputElement
,
'
keyup
'
);
const
onKeyUp
=
domEvent
(
this
.
inputBox
.
inputElement
,
'
keyup
'
);
const
onMouseUp
=
domEvent
(
this
.
inputBox
.
inputElement
,
'
mouseup
'
);
const
onMouseUp
=
domEvent
(
this
.
inputBox
.
inputElement
,
'
mouseup
'
);
anyEvent
<
any
>
(
onKeyUp
,
onMouseUp
)(()
=>
this
.
inputBox
.
validate
(),
null
,
this
.
disposables
);
anyEvent
<
any
>
(
onKeyUp
,
onMouseUp
)(()
=>
validate
(),
null
,
this
.
disposables
);
this
.
inputBox
.
value
=
this
.
repository
.
input
.
value
;
this
.
inputBox
.
value
=
this
.
repository
.
input
.
value
;
this
.
inputBox
.
onDidChange
(
value
=>
this
.
repository
.
input
.
value
=
value
,
null
,
this
.
disposables
);
this
.
inputBox
.
onDidChange
(
value
=>
this
.
repository
.
input
.
value
=
value
,
null
,
this
.
disposables
);
...
...
src/vs/workbench/services/scm/common/scm.ts
浏览文件 @
888f7449
...
@@ -68,6 +68,21 @@ export interface ISCMProvider extends IDisposable {
...
@@ -68,6 +68,21 @@ export interface ISCMProvider extends IDisposable {
getOriginalResource
(
uri
:
URI
):
TPromise
<
URI
>
;
getOriginalResource
(
uri
:
URI
):
TPromise
<
URI
>
;
}
}
export
enum
InputValidationType
{
Error
=
0
,
Warning
=
1
,
Information
=
2
}
export
interface
IInputValidation
{
message
:
string
;
type
:
InputValidationType
;
}
export
interface
IInputValidator
{
(
value
:
string
,
cursorPosition
:
number
):
TPromise
<
IInputValidation
|
undefined
>
;
}
export
interface
ISCMInput
{
export
interface
ISCMInput
{
value
:
string
;
value
:
string
;
readonly
onDidChange
:
Event
<
string
>
;
readonly
onDidChange
:
Event
<
string
>
;
...
@@ -75,7 +90,8 @@ export interface ISCMInput {
...
@@ -75,7 +90,8 @@ export interface ISCMInput {
placeholder
:
string
;
placeholder
:
string
;
readonly
onDidChangePlaceholder
:
Event
<
string
>
;
readonly
onDidChangePlaceholder
:
Event
<
string
>
;
lineWarningLength
:
number
|
undefined
;
validateInput
:
IInputValidator
;
readonly
onDidChangeValidateInput
:
Event
<
void
>
;
}
}
export
interface
ISCMRepository
extends
IDisposable
{
export
interface
ISCMRepository
extends
IDisposable
{
...
...
src/vs/workbench/services/scm/common/scmService.ts
浏览文件 @
888f7449
...
@@ -7,8 +7,9 @@
...
@@ -7,8 +7,9 @@
import
{
IDisposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
ISCMService
,
ISCMProvider
,
ISCMInput
,
ISCMRepository
}
from
'
./scm
'
;
import
{
ISCMService
,
ISCMProvider
,
ISCMInput
,
ISCMRepository
,
IInputValidator
}
from
'
./scm
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
class
SCMInput
implements
ISCMInput
{
class
SCMInput
implements
ISCMInput
{
...
@@ -40,7 +41,19 @@ class SCMInput implements ISCMInput {
...
@@ -40,7 +41,19 @@ class SCMInput implements ISCMInput {
private
_onDidChangePlaceholder
=
new
Emitter
<
string
>
();
private
_onDidChangePlaceholder
=
new
Emitter
<
string
>
();
get
onDidChangePlaceholder
():
Event
<
string
>
{
return
this
.
_onDidChangePlaceholder
.
event
;
}
get
onDidChangePlaceholder
():
Event
<
string
>
{
return
this
.
_onDidChangePlaceholder
.
event
;
}
public
lineWarningLength
:
number
|
undefined
=
undefined
;
private
_validateInput
:
IInputValidator
=
()
=>
TPromise
.
as
(
undefined
);
get
validateInput
():
IInputValidator
{
return
this
.
_validateInput
;
}
set
validateInput
(
validateInput
:
IInputValidator
)
{
this
.
_validateInput
=
validateInput
;
this
.
_onDidChangeValidateInput
.
fire
();
}
private
_onDidChangeValidateInput
=
new
Emitter
<
void
>
();
get
onDidChangeValidateInput
():
Event
<
void
>
{
return
this
.
_onDidChangeValidateInput
.
event
;
}
}
}
class
SCMRepository
implements
ISCMRepository
{
class
SCMRepository
implements
ISCMRepository
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录