Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e0195d75
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,发现更多精彩内容 >>
提交
e0195d75
编写于
8月 22, 2018
作者:
I
isidor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
simplify copy path command
上级
1df5a2f9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
15 addition
and
33 deletion
+15
-33
src/vs/platform/uriLabel/common/uriLabel.ts
src/vs/platform/uriLabel/common/uriLabel.ts
+7
-7
src/vs/workbench/parts/files/electron-browser/fileCommands.ts
...vs/workbench/parts/files/electron-browser/fileCommands.ts
+8
-26
未找到文件。
src/vs/platform/uriLabel/common/uriLabel.ts
浏览文件 @
e0195d75
...
...
@@ -16,7 +16,7 @@ import { ltrim } from 'vs/base/common/strings';
export
interface
IUriLabelService
{
_serviceBrand
:
any
;
getLabel
(
resource
:
URI
,
relative
?:
boolean
):
string
;
getLabel
(
resource
:
URI
,
relative
?:
boolean
,
forceNoTildify
?:
boolean
):
string
;
registerFormater
(
schema
:
string
,
formater
:
UriLabelRules
):
IDisposable
;
onDidRegisterFormater
:
Event
<
{
scheme
:
string
,
formater
:
UriLabelRules
}
>
;
}
...
...
@@ -52,7 +52,7 @@ export class UriLabelService implements IUriLabelService {
return
this
.
_onDidRegisterFormater
.
event
;
}
getLabel
(
resource
:
URI
,
relative
:
boolean
):
string
{
getLabel
(
resource
:
URI
,
relative
:
boolean
,
forceNoTildify
?:
boolean
):
string
{
if
(
!
resource
)
{
return
undefined
;
}
...
...
@@ -68,8 +68,8 @@ export class UriLabelService implements IUriLabelService {
if
(
isEqual
(
baseResource
.
uri
,
resource
,
!
isLinux
))
{
relativeLabel
=
''
;
// no label if resources are identical
}
else
{
const
baseResourceLabel
=
this
.
formatUri
(
baseResource
.
uri
,
formater
);
relativeLabel
=
ltrim
(
this
.
formatUri
(
resource
,
formater
).
substring
(
baseResourceLabel
.
length
),
formater
.
separator
);
const
baseResourceLabel
=
this
.
formatUri
(
baseResource
.
uri
,
formater
,
forceNoTildify
);
relativeLabel
=
ltrim
(
this
.
formatUri
(
resource
,
formater
,
forceNoTildify
).
substring
(
baseResourceLabel
.
length
),
formater
.
separator
);
}
const
hasMultipleRoots
=
this
.
contextService
.
getWorkspace
().
folders
.
length
>
1
;
...
...
@@ -82,7 +82,7 @@ export class UriLabelService implements IUriLabelService {
}
}
return
this
.
formatUri
(
resource
,
formater
);
return
this
.
formatUri
(
resource
,
formater
,
forceNoTildify
);
}
registerFormater
(
scheme
:
string
,
formater
:
UriLabelRules
):
IDisposable
{
...
...
@@ -94,7 +94,7 @@ export class UriLabelService implements IUriLabelService {
};
}
private
formatUri
(
resource
:
URI
,
formater
:
UriLabelRules
):
string
{
private
formatUri
(
resource
:
URI
,
formater
:
UriLabelRules
,
forceNoTildify
:
boolean
):
string
{
let
label
=
formater
.
label
.
replace
(
labelMatchingRegexp
,
match
=>
{
switch
(
match
)
{
case
'
${scheme}
'
:
return
resource
.
scheme
;
...
...
@@ -109,7 +109,7 @@ export class UriLabelService implements IUriLabelService {
label
=
label
.
charAt
(
1
).
toUpperCase
()
+
label
.
substr
(
2
);
}
if
(
formater
.
tildify
)
{
if
(
formater
.
tildify
&&
!
forceNoTildify
)
{
label
=
tildify
(
label
,
this
.
environmentService
.
userHome
);
}
...
...
src/vs/workbench/parts/files/electron-browser/fileCommands.ts
浏览文件 @
e0195d75
...
...
@@ -8,7 +8,6 @@
import
*
as
nls
from
'
vs/nls
'
;
import
*
as
paths
from
'
vs/base/common/paths
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
*
as
labels
from
'
vs/base/common/labels
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
toResource
,
IEditorCommandsContext
}
from
'
vs/workbench/common/editor
'
;
import
{
IWindowsService
,
IWindowService
}
from
'
vs/platform/windows/common/windows
'
;
...
...
@@ -31,7 +30,7 @@ import { IEditorViewState } from 'vs/editor/common/editorCommon';
import
{
getCodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
KeybindingsRegistry
,
KeybindingWeight
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
KeyMod
,
KeyCode
,
KeyChord
}
from
'
vs/base/common/keyCodes
'
;
import
{
isWindows
,
isMacintosh
,
isLinux
}
from
'
vs/base/common/platform
'
;
import
{
isWindows
,
isMacintosh
}
from
'
vs/base/common/platform
'
;
import
{
ITextModelService
}
from
'
vs/editor/common/services/resolverService
'
;
import
{
sequence
}
from
'
vs/base/common/async
'
;
import
{
getResourceForCommand
,
getMultiSelectedResources
}
from
'
vs/workbench/parts/files/browser/files
'
;
...
...
@@ -42,8 +41,7 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
import
{
EditorContextKeys
}
from
'
vs/editor/common/editorContextKeys
'
;
import
{
IEditorService
,
SIDE_GROUP
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IEditorGroupsService
}
from
'
vs/workbench/services/group/common/editorGroupsService
'
;
import
{
isEqual
,
basenameOrAuthority
}
from
'
vs/base/common/resources
'
;
import
{
ltrim
}
from
'
vs/base/common/strings
'
;
import
{
IUriLabelService
}
from
'
vs/platform/uriLabel/common/uriLabel
'
;
// Commands
...
...
@@ -389,28 +387,12 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
}
});
function
resourcesToClipboard
(
resources
:
URI
[],
clipboardService
:
IClipboardService
,
notificationService
:
INotificationService
,
contextService
?:
IWorkspaceContext
Service
):
void
{
function
resourcesToClipboard
(
resources
:
URI
[],
relative
:
boolean
,
clipboardService
:
IClipboardService
,
notificationService
:
INotificationService
,
uriLabelService
:
IUriLabel
Service
):
void
{
if
(
resources
.
length
)
{
const
lineDelimiter
=
isWindows
?
'
\r\n
'
:
'
\n
'
;
const
text
=
resources
.
map
(
resource
=>
{
if
(
contextService
)
{
const
workspaceFolder
=
contextService
.
getWorkspaceFolder
(
resource
);
if
(
workspaceFolder
)
{
if
(
isEqual
(
workspaceFolder
.
uri
,
resource
,
!
isLinux
))
{
return
basenameOrAuthority
(
workspaceFolder
.
uri
);
}
return
paths
.
normalize
(
ltrim
(
resource
.
path
.
substr
(
workspaceFolder
.
uri
.
path
.
length
),
paths
.
sep
),
true
);
}
}
if
(
resource
.
scheme
===
Schemas
.
file
)
{
return
paths
.
normalize
(
labels
.
normalizeDriveLetter
(
resource
.
fsPath
),
true
);
}
return
resource
.
toString
();
}).
join
(
lineDelimiter
);
const
text
=
resources
.
map
(
resource
=>
uriLabelService
.
getLabel
(
resource
,
relative
,
true
))
.
join
(
lineDelimiter
);
clipboardService
.
writeText
(
text
);
}
else
{
notificationService
.
info
(
nls
.
localize
(
'
openFileToCopy
'
,
"
Open a file first to copy its path
"
));
...
...
@@ -427,7 +409,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
id
:
COPY_PATH_COMMAND_ID
,
handler
:
(
accessor
,
resource
:
URI
|
object
)
=>
{
const
resources
=
getMultiSelectedResources
(
resource
,
accessor
.
get
(
IListService
),
accessor
.
get
(
IEditorService
));
resourcesToClipboard
(
resources
,
accessor
.
get
(
IClipboardService
),
accessor
.
get
(
INotification
Service
));
resourcesToClipboard
(
resources
,
false
,
accessor
.
get
(
IClipboardService
),
accessor
.
get
(
INotificationService
),
accessor
.
get
(
IUriLabel
Service
));
}
});
...
...
@@ -441,7 +423,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
id
:
COPY_RELATIVE_PATH_COMMAND_ID
,
handler
:
(
accessor
,
resource
:
URI
|
object
)
=>
{
const
resources
=
getMultiSelectedResources
(
resource
,
accessor
.
get
(
IListService
),
accessor
.
get
(
IEditorService
));
resourcesToClipboard
(
resources
,
accessor
.
get
(
IClipboardService
),
accessor
.
get
(
INotificationService
),
accessor
.
get
(
IWorkspaceContext
Service
));
resourcesToClipboard
(
resources
,
true
,
accessor
.
get
(
IClipboardService
),
accessor
.
get
(
INotificationService
),
accessor
.
get
(
IUriLabel
Service
));
}
});
...
...
@@ -454,7 +436,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
const
editorService
=
accessor
.
get
(
IEditorService
);
const
activeInput
=
editorService
.
activeEditor
;
const
resources
=
activeInput
&&
activeInput
.
getResource
()
?
[
activeInput
.
getResource
()]
:
[];
resourcesToClipboard
(
resources
,
accessor
.
get
(
IClipboardService
),
accessor
.
get
(
INotification
Service
));
resourcesToClipboard
(
resources
,
false
,
accessor
.
get
(
IClipboardService
),
accessor
.
get
(
INotificationService
),
accessor
.
get
(
IUriLabel
Service
));
}
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录