Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
91b7e602
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,发现更多精彩内容 >>
未验证
提交
91b7e602
编写于
5月 31, 2021
作者:
M
Martin Aeschlimann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move vscode.newWindow & vscode.removeFromRecentlyOpened out of apiCommands. For #110583
上级
2ae32273
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
90 addition
and
132 deletion
+90
-132
src/vs/workbench/api/common/apiCommands.ts
src/vs/workbench/api/common/apiCommands.ts
+0
-79
src/vs/workbench/api/common/extHostApiCommands.ts
src/vs/workbench/api/common/extHostApiCommands.ts
+0
-51
src/vs/workbench/browser/actions/workspaceCommands.ts
src/vs/workbench/browser/actions/workspaceCommands.ts
+90
-2
未找到文件。
src/vs/workbench/api/common/apiCommands.ts
浏览文件 @
91b7e602
...
...
@@ -7,8 +7,6 @@ import { URI } from 'vs/base/common/uri';
import
*
as
typeConverters
from
'
vs/workbench/api/common/extHostTypeConverters
'
;
import
{
CommandsRegistry
,
ICommandService
,
ICommandHandler
}
from
'
vs/platform/commands/common/commands
'
;
import
{
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IOpenEmptyWindowOptions
}
from
'
vs/platform/windows/common/windows
'
;
import
{
IWorkspacesService
,
IRecent
}
from
'
vs/platform/workspaces/common/workspaces
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IViewDescriptorService
,
IViewsService
,
ViewVisibilityState
}
from
'
vs/workbench/common/views
'
;
...
...
@@ -30,83 +28,6 @@ function adjustHandler(handler: (executor: ICommandsExecutor, ...args: any[]) =>
};
}
interface
INewWindowAPICommandOptions
{
reuseWindow
?:
boolean
;
/**
* If set, defines the remoteAuthority of the new window. `null` will open a local window.
* If not set, defaults to remoteAuthority of the current window.
*/
remoteAuthority
?:
string
|
null
;
}
export
class
NewWindowAPICommand
{
public
static
readonly
ID
=
'
vscode.newWindow
'
;
public
static
execute
(
executor
:
ICommandsExecutor
,
options
?:
INewWindowAPICommandOptions
):
Promise
<
any
>
{
const
commandOptions
:
IOpenEmptyWindowOptions
=
{
forceReuseWindow
:
options
&&
options
.
reuseWindow
,
remoteAuthority
:
options
&&
options
.
remoteAuthority
};
return
executor
.
executeCommand
(
'
_files.newWindow
'
,
commandOptions
);
}
}
CommandsRegistry
.
registerCommand
({
id
:
NewWindowAPICommand
.
ID
,
handler
:
adjustHandler
(
NewWindowAPICommand
.
execute
),
description
:
{
description
:
'
Opens an new window
'
,
args
:
[
]
}
});
CommandsRegistry
.
registerCommand
(
'
_workbench.removeFromRecentlyOpened
'
,
function
(
accessor
:
ServicesAccessor
,
uri
:
URI
)
{
const
workspacesService
=
accessor
.
get
(
IWorkspacesService
);
return
workspacesService
.
removeRecentlyOpened
([
uri
]);
});
export
class
RemoveFromRecentlyOpenedAPICommand
{
public
static
readonly
ID
=
'
vscode.removeFromRecentlyOpened
'
;
public
static
execute
(
executor
:
ICommandsExecutor
,
path
:
string
|
URI
):
Promise
<
any
>
{
if
(
typeof
path
===
'
string
'
)
{
path
=
path
.
match
(
/^
[^
:
/
?#
]
+:
\/\/
/
)
?
URI
.
parse
(
path
)
:
URI
.
file
(
path
);
}
else
{
path
=
URI
.
revive
(
path
);
// called from extension host
}
return
executor
.
executeCommand
(
'
_workbench.removeFromRecentlyOpened
'
,
path
);
}
}
CommandsRegistry
.
registerCommand
(
RemoveFromRecentlyOpenedAPICommand
.
ID
,
adjustHandler
(
RemoveFromRecentlyOpenedAPICommand
.
execute
));
interface
RecentEntry
{
uri
:
URI
;
type
:
'
workspace
'
|
'
folder
'
|
'
file
'
;
label
?:
string
;
remoteAuthority
?:
string
;
}
CommandsRegistry
.
registerCommand
(
'
_workbench.addToRecentlyOpened
'
,
async
function
(
accessor
:
ServicesAccessor
,
recentEntry
:
RecentEntry
)
{
const
workspacesService
=
accessor
.
get
(
IWorkspacesService
);
let
recent
:
IRecent
|
undefined
=
undefined
;
const
uri
=
recentEntry
.
uri
;
const
label
=
recentEntry
.
label
;
const
remoteAuthority
=
recentEntry
.
remoteAuthority
;
if
(
recentEntry
.
type
===
'
workspace
'
)
{
const
workspace
=
await
workspacesService
.
getWorkspaceIdentifier
(
uri
);
recent
=
{
workspace
,
label
,
remoteAuthority
};
}
else
if
(
recentEntry
.
type
===
'
folder
'
)
{
recent
=
{
folderUri
:
uri
,
label
,
remoteAuthority
};
}
else
{
recent
=
{
fileUri
:
uri
,
label
,
remoteAuthority
};
}
return
workspacesService
.
addRecentlyOpened
([
recent
]);
});
CommandsRegistry
.
registerCommand
(
'
_workbench.getRecentlyOpened
'
,
async
function
(
accessor
:
ServicesAccessor
)
{
const
workspacesService
=
accessor
.
get
(
IWorkspacesService
);
return
workspacesService
.
getRecentlyOpened
();
});
CommandsRegistry
.
registerCommand
(
'
_extensionTests.setLogLevel
'
,
function
(
accessor
:
ServicesAccessor
,
level
:
number
)
{
const
logService
=
accessor
.
get
(
ILogService
);
const
environmentService
=
accessor
.
get
(
IEnvironmentService
);
...
...
src/vs/workbench/api/common/extHostApiCommands.ts
浏览文件 @
91b7e602
...
...
@@ -4,17 +4,14 @@
*--------------------------------------------------------------------------------------------*/
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
DisposableStore
}
from
'
vs/base/common/lifecycle
'
;
import
type
*
as
vscode
from
'
vscode
'
;
import
*
as
typeConverters
from
'
vs/workbench/api/common/extHostTypeConverters
'
;
import
*
as
types
from
'
vs/workbench/api/common/extHostTypes
'
;
import
{
IRawColorInfo
,
IWorkspaceEditDto
,
ICallHierarchyItemDto
,
IIncomingCallDto
,
IOutgoingCallDto
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
*
as
modes
from
'
vs/editor/common/modes
'
;
import
*
as
search
from
'
vs/workbench/contrib/search/common/search
'
;
import
{
ICommandHandlerDescription
}
from
'
vs/platform/commands/common/commands
'
;
import
{
ApiCommand
,
ApiCommandArgument
,
ApiCommandResult
,
ExtHostCommands
}
from
'
vs/workbench/api/common/extHostCommands
'
;
import
{
CustomCodeAction
}
from
'
vs/workbench/api/common/extHostLanguageFeatures
'
;
import
{
ICommandsExecutor
,
RemoveFromRecentlyOpenedAPICommand
}
from
'
./apiCommands
'
;
import
{
isFalsyOrEmpty
}
from
'
vs/base/common/arrays
'
;
import
{
IRange
}
from
'
vs/editor/common/core/range
'
;
import
{
IPosition
}
from
'
vs/editor/common/core/position
'
;
...
...
@@ -420,56 +417,8 @@ export class ExtHostApiCommands {
static
register
(
commands
:
ExtHostCommands
)
{
newCommands
.
forEach
(
commands
.
registerApiCommand
,
commands
);
return
new
ExtHostApiCommands
(
commands
).
registerCommands
();
}
private
_commands
:
ExtHostCommands
;
private
readonly
_disposables
=
new
DisposableStore
();
private
constructor
(
commands
:
ExtHostCommands
)
{
this
.
_commands
=
commands
;
}
registerCommands
()
{
// -----------------------------------------------------------------
// The following commands are registered on both sides separately.
//
// We are trying to maintain backwards compatibility for cases where
// API commands are encoded as markdown links, for example.
// -----------------------------------------------------------------
type
ICommandHandler
=
(...
args
:
any
[])
=>
any
;
const
adjustHandler
=
(
handler
:
(
executor
:
ICommandsExecutor
,
...
args
:
any
[])
=>
any
):
ICommandHandler
=>
{
return
(...
args
:
any
[])
=>
{
return
handler
(
this
.
_commands
,
...
args
);
};
};
this
.
_register
(
RemoveFromRecentlyOpenedAPICommand
.
ID
,
adjustHandler
(
RemoveFromRecentlyOpenedAPICommand
.
execute
),
{
description
:
'
Removes an entry with the given path from the recently opened list.
'
,
args
:
[
{
name
:
'
path
'
,
description
:
'
Path to remove from recently opened.
'
,
constraint
:
(
value
:
any
)
=>
typeof
value
===
'
string
'
}
]
});
}
// --- command impl
/**
* @deprecated use the ApiCommand instead
*/
private
_register
(
id
:
string
,
handler
:
(...
args
:
any
[])
=>
any
,
description
?:
ICommandHandlerDescription
):
void
{
const
disposable
=
this
.
_commands
.
registerCommand
(
false
,
id
,
handler
,
this
,
description
);
this
.
_disposables
.
add
(
disposable
);
}
}
function
tryMapWith
<
T
,
R
>
(
f
:
(
x
:
T
)
=>
R
)
{
...
...
src/vs/workbench/browser/actions/workspaceCommands.ts
浏览文件 @
91b7e602
...
...
@@ -20,8 +20,8 @@ import { IModeService } from 'vs/editor/common/services/modeService';
import
{
IFileDialogService
,
IPickAndOpenOptions
}
from
'
vs/platform/dialogs/common/dialogs
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
IOpenWindowOptions
,
IWindowOpenable
}
from
'
vs/platform/windows/common/windows
'
;
import
{
hasWorkspaceFileExtension
}
from
'
vs/platform/workspaces/common/workspaces
'
;
import
{
IOpen
EmptyWindowOptions
,
IOpen
WindowOptions
,
IWindowOpenable
}
from
'
vs/platform/windows/common/windows
'
;
import
{
hasWorkspaceFileExtension
,
IRecent
,
IWorkspacesService
}
from
'
vs/platform/workspaces/common/workspaces
'
;
import
{
IPathService
}
from
'
vs/workbench/services/path/common/pathService
'
;
import
{
ILocalizedString
}
from
'
vs/platform/actions/common/actions
'
;
...
...
@@ -185,3 +185,91 @@ CommandsRegistry.registerCommand({
]
}
});
interface
INewWindowAPICommandOptions
{
reuseWindow
?:
boolean
;
/**
* If set, defines the remoteAuthority of the new window. `null` will open a local window.
* If not set, defaults to remoteAuthority of the current window.
*/
remoteAuthority
?:
string
|
null
;
}
CommandsRegistry
.
registerCommand
({
id
:
'
vscode.newWindow
'
,
handler
:
(
accessor
:
ServicesAccessor
,
options
?:
INewWindowAPICommandOptions
)
=>
{
const
commandOptions
:
IOpenEmptyWindowOptions
=
{
forceReuseWindow
:
options
&&
options
.
reuseWindow
,
remoteAuthority
:
options
&&
options
.
remoteAuthority
};
const
commandService
=
accessor
.
get
(
ICommandService
);
return
commandService
.
executeCommand
(
'
_files.newWindow
'
,
commandOptions
);
},
description
:
{
description
:
'
Opens an new window depending on the newWindow argument.
'
,
args
:
[
{
name
:
'
options
'
,
description
:
'
(optional) Options. Object with the following properties:
'
+
'
`reuseWindow`: Whether to open a new window or the same. Defaults to opening in a new window.
'
,
constraint
:
(
value
:
any
)
=>
value
===
undefined
||
typeof
value
===
'
object
'
}
]
}
});
// recent history commands
CommandsRegistry
.
registerCommand
(
'
_workbench.removeFromRecentlyOpened
'
,
function
(
accessor
:
ServicesAccessor
,
uri
:
URI
)
{
const
workspacesService
=
accessor
.
get
(
IWorkspacesService
);
return
workspacesService
.
removeRecentlyOpened
([
uri
]);
});
CommandsRegistry
.
registerCommand
({
id
:
'
vscode.removeFromRecentlyOpened
'
,
handler
:
(
accessor
:
ServicesAccessor
,
path
:
string
|
URI
):
Promise
<
any
>
=>
{
if
(
typeof
path
===
'
string
'
)
{
path
=
path
.
match
(
/^
[^
:
/
?#
]
+:
\/\/
/
)
?
URI
.
parse
(
path
)
:
URI
.
file
(
path
);
}
else
{
path
=
URI
.
revive
(
path
);
// called from extension host
}
const
workspacesService
=
accessor
.
get
(
IWorkspacesService
);
return
workspacesService
.
removeRecentlyOpened
([
path
]);
},
description
:
{
description
:
'
Removes an entry with the given path from the recently opened list.
'
,
args
:
[
{
name
:
'
path
'
,
description
:
'
URI or URI string to remove from recently opened.
'
,
constraint
:
(
value
:
any
)
=>
typeof
value
===
'
string
'
||
value
instanceof
URI
}
]
}
});
interface
RecentEntry
{
uri
:
URI
;
type
:
'
workspace
'
|
'
folder
'
|
'
file
'
;
label
?:
string
;
remoteAuthority
?:
string
;
}
CommandsRegistry
.
registerCommand
(
'
_workbench.addToRecentlyOpened
'
,
async
function
(
accessor
:
ServicesAccessor
,
recentEntry
:
RecentEntry
)
{
const
workspacesService
=
accessor
.
get
(
IWorkspacesService
);
let
recent
:
IRecent
|
undefined
=
undefined
;
const
uri
=
recentEntry
.
uri
;
const
label
=
recentEntry
.
label
;
const
remoteAuthority
=
recentEntry
.
remoteAuthority
;
if
(
recentEntry
.
type
===
'
workspace
'
)
{
const
workspace
=
await
workspacesService
.
getWorkspaceIdentifier
(
uri
);
recent
=
{
workspace
,
label
,
remoteAuthority
};
}
else
if
(
recentEntry
.
type
===
'
folder
'
)
{
recent
=
{
folderUri
:
uri
,
label
,
remoteAuthority
};
}
else
{
recent
=
{
fileUri
:
uri
,
label
,
remoteAuthority
};
}
return
workspacesService
.
addRecentlyOpened
([
recent
]);
});
CommandsRegistry
.
registerCommand
(
'
_workbench.getRecentlyOpened
'
,
async
function
(
accessor
:
ServicesAccessor
)
{
const
workspacesService
=
accessor
.
get
(
IWorkspacesService
);
return
workspacesService
.
getRecentlyOpened
();
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录