Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class ExternalChangeWatcher(

// Active worktree symlink changed (scoped to its parent directory)
if (fileName == config?.activeWorktree?.fileName?.toString()
&& watchedPath == config?.activeWorktree?.parent) return true
&& watchedPath == config.activeWorktree.parent) return true

// .git/worktrees/ changes — worktree created/removed
val gitWorktreesDir = config?.mainRepoRoot?.resolve(".git/worktrees")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.intellij.openapi.progress.ProgressIndicator
import com.intellij.openapi.progress.ProgressManager
import com.intellij.openapi.progress.Task
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.RootsChangeRescanningInfo
import com.intellij.openapi.roots.ex.ProjectRootManagerEx
import com.intellij.openapi.vcs.ProjectLevelVcsManager
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager
Expand Down Expand Up @@ -132,7 +133,8 @@ class SymlinkSwitchService(

// Fire synthetic roots-changed event so indexer and module system see the new tree
WriteAction.run<Nothing> {
ProjectRootManagerEx.getInstanceEx(project).makeRootsChange({}, false, true)
ProjectRootManagerEx.getInstanceEx(project)
.makeRootsChange({}, RootsChangeRescanningInfo.TOTAL_RESCAN)
}

ProjectView.getInstance(project).refresh()
Expand All @@ -147,7 +149,7 @@ class SymlinkSwitchService(
indicator?.text = "Updating git state..."
app.invokeAndWait({
val vcsManager = ProjectLevelVcsManager.getInstance(project)
vcsManager.setDirectoryMappings(vcsManager.directoryMappings.toList())
vcsManager.setDirectoryMappings(vcsManager.getDirectoryMappings().toList())
}, ModalityState.defaultModalityState())
withContext(Dispatchers.IO) {
val repos = GitRepositoryManager.getInstance(project).repositories
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ import com.block.wt.services.WorktreeService
import com.block.wt.settings.WtPluginSettings
import com.intellij.ide.BrowserUtil
import com.intellij.openapi.Disposable
import com.intellij.ide.DataManager
import com.intellij.openapi.actionSystem.ActionManager
import com.intellij.openapi.actionSystem.ActionPlaces
import com.intellij.openapi.actionSystem.ActionUiKind
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.DataKey
import com.intellij.openapi.actionSystem.DataProvider
import com.intellij.openapi.actionSystem.DefaultActionGroup
Expand Down Expand Up @@ -203,7 +207,7 @@ class WorktreePanel(private val project: Project) : JPanel(BorderLayout()), Data
button("Add Context...") {
val action = ActionManager.getInstance().getAction("Wt.AddContext")
if (action != null) {
ActionUtil.invokeAction(action, this@WorktreePanel, ActionPlaces.TOOLWINDOW_CONTENT, null, null)
invokeAction(action)
}
}.align(Align.CENTER)
}
Expand Down Expand Up @@ -401,6 +405,18 @@ class WorktreePanel(private val project: Project) : JPanel(BorderLayout()), Data
}
}

private fun invokeAction(action: AnAction) {
val dataContext = DataManager.getInstance().getDataContext(this@WorktreePanel)
val event = AnActionEvent.createEvent(
dataContext,
action.templatePresentation.clone(),
ActionPlaces.TOOLWINDOW_CONTENT,
ActionUiKind.NONE,
null
)
ActionUtil.performAction(action, event)
}

private fun handlePRClick(wt: WorktreeInfo) {
when (val pr = wt.prInfo) {
is PullRequestInfo.Open,
Expand All @@ -410,22 +426,21 @@ class WorktreePanel(private val project: Project) : JPanel(BorderLayout()), Data
// Try to show the PR for the current branch in the Pull Requests tool window
val showAction = ActionManager.getInstance().getAction("Github.Pull.Request.Show.In.Toolwindow")
if (showAction != null) {
ActionUtil.invokeAction(showAction, this@WorktreePanel, ActionPlaces.TOOLWINDOW_CONTENT, null, null)
invokeAction(showAction)
} else {
val url = when (pr) {
is PullRequestInfo.Open -> pr.url
is PullRequestInfo.Draft -> pr.url
is PullRequestInfo.Merged -> pr.url
is PullRequestInfo.Closed -> pr.url
else -> return
}
BrowserUtil.browse(url)
}
}
is PullRequestInfo.NoPR -> {
val createAction = ActionManager.getInstance().getAction("Github.Create.Pull.Request")
if (createAction != null) {
ActionUtil.invokeAction(createAction, this@WorktreePanel, ActionPlaces.TOOLWINDOW_CONTENT, null, null)
invokeAction(createAction)
} else {
val branch = wt.branch ?: return
val slug = WorktreeService.getInstance(project).repoSlug ?: return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ class TerminalNavigatorTest {
// PID 999999999 should not exist — should not crash
val tty = TerminalNavigator.resolveTty(999999999L)
// Result is null when PID doesn't exist (ps returns no output or error)
// This test just verifies no exception is thrown
assertTrue(tty == null || tty is String)
// This test just verifies no exception is thrown — reaching here means success
}

// --- Terminal owner resolution ---
Expand All @@ -53,7 +52,7 @@ class TerminalNavigatorTest {
fun testGetProcessCommForNonexistentPid() {
// Should not crash for non-existent PID
val comm = TerminalNavigator.getProcessComm(999999999L)
assertTrue(comm == null || comm is String)
// This test just verifies no exception is thrown — reaching here means success
}

@Test
Expand Down