[leas code] Simplify boolean guards (#13401)
* refactor: remove unreachable code * refactor: simplify boolean guards
This commit is contained in:
parent
3b1017c4fb
commit
8a33ce2536
|
|
@ -10,16 +10,10 @@ export function getVisibleRightSidebarActivityItems(
|
|||
items: ActivityBarItem[],
|
||||
{ isFolder, isFolderWorkspace, isSshRepo }: RightSidebarActivityVisibilityState
|
||||
): ActivityBarItem[] {
|
||||
return items.filter((item) => {
|
||||
if (item.gitOnly && isFolder) {
|
||||
return false
|
||||
}
|
||||
if (item.folderOnly && !isFolderWorkspace) {
|
||||
return false
|
||||
}
|
||||
if (item.sshOnly && !isSshRepo) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
return items.filter(
|
||||
(item) =>
|
||||
(!item.gitOnly || !isFolder) &&
|
||||
(!item.folderOnly || isFolderWorkspace) &&
|
||||
(!item.sshOnly || isSshRepo)
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,19 +5,13 @@ export function shouldRepairActiveTerminalTab(args: {
|
|||
activeTabId: string | null
|
||||
tabs: TerminalTab[]
|
||||
}): boolean {
|
||||
if (args.activeTabType !== 'terminal') {
|
||||
return false
|
||||
}
|
||||
if (args.tabs.length === 0) {
|
||||
return false
|
||||
}
|
||||
if (args.activeTabId && args.tabs.some((tab) => tab.id === args.activeTabId)) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
return (
|
||||
args.activeTabType === 'terminal' &&
|
||||
args.tabs.length > 0 &&
|
||||
(!args.activeTabId || !args.tabs.some((tab) => tab.id === args.activeTabId))
|
||||
)
|
||||
}
|
||||
|
||||
// Resolve which terminal tab to open after a project/agent is selected, or null if no repair is needed.
|
||||
export function resolveRepairedActiveTerminalTabId(args: {
|
||||
activeTabType: WorkspaceVisibleTabType
|
||||
activeTabId: string | null
|
||||
|
|
|
|||
|
|
@ -1,21 +1,8 @@
|
|||
/**
|
||||
* Returns true when an Enter keydown event should be suppressed for submit actions.
|
||||
*
|
||||
* Two cases must be blocked:
|
||||
* 1. IME composition is active — Enter only confirms the conversion candidate.
|
||||
* 2. Shift+Enter inside a textarea — intended as a newline, not a submit.
|
||||
*/
|
||||
export function shouldSuppressEnterSubmit(
|
||||
event: { isComposing: boolean; shiftKey: boolean },
|
||||
isTextarea: boolean
|
||||
): boolean {
|
||||
if (event.isComposing) {
|
||||
return true
|
||||
}
|
||||
if (isTextarea && event.shiftKey) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return event.isComposing || (isTextarea && event.shiftKey)
|
||||
}
|
||||
|
||||
export function shouldAllowComposerEnterSubmitTarget(
|
||||
|
|
|
|||
|
|
@ -84,16 +84,12 @@ export function resolveWindowsShellOverride(
|
|||
* local pane from a serve pane, so callers gate it with `isLocalNativeWindowsConpty`.
|
||||
*/
|
||||
export function isLocalNativeWindowsPty(context: WindowsPtyCompatibilityContext): boolean {
|
||||
if (!isWindowsUserAgent(context.userAgent)) {
|
||||
return false
|
||||
}
|
||||
if (context.connectionId !== null) {
|
||||
return false
|
||||
}
|
||||
if (isWslCwd(context.cwd) || isWslShellOverride(context.shellOverride)) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
return (
|
||||
isWindowsUserAgent(context.userAgent) &&
|
||||
context.connectionId === null &&
|
||||
!isWslCwd(context.cwd) &&
|
||||
!isWslShellOverride(context.shellOverride)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -34,18 +34,13 @@ export function hasInteractiveActiveGitStatusConsumer(args: ActiveGitStatusPolli
|
|||
if (!args.activeWorktreeId || !args.worktreePath) {
|
||||
return false
|
||||
}
|
||||
if (
|
||||
args.rightSidebarOpen &&
|
||||
(args.rightSidebarTab === 'source-control' ||
|
||||
(args.rightSidebarTab === 'explorer' && args.rightSidebarExplorerView !== 'search') ||
|
||||
args.rightSidebarTab === 'checks')
|
||||
) {
|
||||
return true
|
||||
}
|
||||
if ((args.openFiles ?? []).some((file) => file.worktreeId === args.activeWorktreeId)) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return (
|
||||
(args.rightSidebarOpen &&
|
||||
(args.rightSidebarTab === 'source-control' ||
|
||||
(args.rightSidebarTab === 'explorer' && args.rightSidebarExplorerView !== 'search') ||
|
||||
args.rightSidebarTab === 'checks')) ||
|
||||
(args.openFiles ?? []).some((file) => file.worktreeId === args.activeWorktreeId)
|
||||
)
|
||||
}
|
||||
|
||||
export function shouldPollActiveGitStatus(args: ActiveGitStatusPollingArgs): boolean {
|
||||
|
|
|
|||
Loading…
Reference in New Issue