Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BR] Focus doesn't focus once terminal is created #190

Closed
2 of 4 tasks
jeff-hykin opened this issue Oct 20, 2020 · 14 comments · Fixed by #292
Closed
2 of 4 tasks

[BR] Focus doesn't focus once terminal is created #190

jeff-hykin opened this issue Oct 20, 2020 · 14 comments · Fixed by #292
Labels
bug report 🐛 When something isn't working released unable to duplicate !! When the issue cannot be duplicated

Comments

@jeff-hykin
Copy link
Contributor

jeff-hykin commented Oct 20, 2020

  • I have reset Atom to defaults prior to submitting report.
  • I have not reset Atom to defaults prior to submitting report.
  • I have tried uninstalling/reinstalling the terminal.
  • I have not tried uninstalling/reinstalling the terminal.

Description

Steps to reproduce

  1. Open Atom
  2. Call x-terminal:focus through a keybinding
  3. Terminal opens 👍
  4. Close the panel
  5. Call x-terminal:focus through a keybinding
  6. Nothing happens

Expected behavior:
The terminal to be focused on (open bottom panel)

Actual behavior:
Nothing

Reproduces how often:
100%

Versions

> atom --version
Atom    : 1.50.0
Electron: 5.0.13
Chrome  : 73.0.3683.121
Node    : 12.0.0
> apm --version
apm  2.5.0
npm  6.14.5
node 10.20.1 x64
atom 1.50.0
python 3.9.0a4
git 2.27.0

OS name and version: MacOS Sierra
Terminal version: 11.0.2

Additional context

This might be something wrong with atom since the last fix related to focus is just calling focus twice, which is kinda jank
#175
I've tested directly calling the commands (no keybinding) as well just to make sure there wasn't an issue with activation

@jeff-hykin jeff-hykin added the bug report 🐛 Something isn't working label Oct 20, 2020
@jeff-hykin
Copy link
Contributor Author

This is the hack I'm using to get around it

atom.commands.add('body', 'terminal:toggle', async ()=>{
    let terminalIsFocused = !!document.querySelector("atom-panel-container.bottom .xterm-helper-textarea:focus")
    console.log( 'terminalIsFocused', terminalIsFocused)
    if (!terminalIsFocused) {
        let bottomDockIsOpen = !!document.querySelector(".atom-dock-inner.bottom.atom-dock-open")
        // open if not open
        if (!bottomDockIsOpen) {
            await atom.workspace.getBottomDock().toggle()
        }
        // select the terminal
        selectLastOpenTerminal()
        // force focus (useful when terminal is open, panel is open, but textbox not selected)
        setTimeout(((event)=>{
            let area = document.querySelector(".xterm-helper-textarea")
            if (area) {
                area.focus() 
            }
        }), 0)
    } else {
        let bottomDockIsOpen = !!document.querySelector(".atom-dock-inner.bottom.atom-dock-open")
        console.log('bottomDockIsOpen', bottomDockIsOpen)
        // if open, close it
        if (bottomDockIsOpen) {
            atom.workspace.getBottomDock().toggle()
        }
        // focus on the main view
        atom.views.getView(atom.workspace).focus()
    }
})

function selectLastOpenTerminal() {
    let dock = atom.workspace.getBottomDock()
    let atLeastOneExists = false
    for (let each of dock.getPaneItems()) {
      if (each.__proto__.constructor.name.match(/XTerminal/)) {
        atLeastOneExists = each
        if (each.activeIndex == 0) {
          return dock.paneContainer.activePane.activateItem(each)
        }
      }
    }
    if (atLeastOneExists) {
      return dock.paneContainer.activePane.activateItem(atLeastOneExists)
    } else {
      return atom.commands.selectorBasedListenersByCommandName["x-terminal:open"][0].didDispatch()
    }
}

@UziTech
Copy link
Member

UziTech commented Oct 21, 2020

Hmm, Seems to work for me.

xterm

@UziTech UziTech added bug report 🐛 When something isn't working unable to duplicate !! When the issue cannot be duplicated and removed bug report 🐛 Something isn't working labels Oct 21, 2020
@UziTech
Copy link
Member

UziTech commented Oct 21, 2020

I'm on Windows 10 Atom v1.53.0-beta.

This could just be an issue with mac or Atom v1.52.0 upgraded to Electron 6 maybe updating Atom will fix it for you?

@jeff-hykin
Copy link
Contributor Author

jeff-hykin commented Oct 21, 2020

yeah after poking the system making that workaround, it very well could be Atom core. I grabbed the terminal object and manually called focus and nothing would happen. I'll try uninstalling and re-installing methods.

We really need to make upgrades more reliable on Atom :/ seems like everything requires a full uninstall

@the-j0k3r
Copy link
Member

We really need to make upgrades more reliable on Atom :/ seems like everything requires a full uninstall

apm and node-gyp are pretty much the points of failure, very unreliable especially for native modules upgrades, like node-pty-prebuilt-multiarch from electron 5.x to 6.x, and you cant do a simple app upgrade when the Atom session has the app running, it simply breaks.

@jeff-hykin
Copy link
Contributor Author

jeff-hykin commented Oct 21, 2020

@the-j0k3r yeah, I think node-gyp is the root source of 99.9% of all problems (on any node.js project). It looks like x-terminal can't exist without native modules though

@UziTech
Copy link
Member

UziTech commented Nov 19, 2020

@jeff-hykin did you ever get this working? The steps to reproduce seem to work for me.

@jeff-hykin
Copy link
Contributor Author

jeff-hykin commented Nov 20, 2020

Sadly no :/ I downloaded atom just now, opened it up installed a fresh x-terminal, cmd+T to open a terminal. Shrank it, called the X-terminal focus command manually from the command pallet and... nothing :/ I'll try to get me debugging info

@jeff-hykin
Copy link
Contributor Author

jeff-hykin commented Nov 24, 2020

Is there a package lock inside a standard atom install? debugging isn't terribly straightforward since stuff like the focus commands just... don't do the thing they're supposed to and don't print any errors.

@UziTech
Copy link
Member

UziTech commented Nov 24, 2020

I'm not sure what you mean. There is a package-lock.json file. This issue must have to do with MacOS. I have tested this on windows and ubuntu and both work, however I don't have a way to test on MacOS.

@jeff-hykin
Copy link
Contributor Author

jeff-hykin commented Nov 26, 2020

Oh, that applies for all the extensions too? I could just be being dumb.

I think the issue is related to having previous installs of Atom. There's application caches, and stuff in the home folder. I'll upload my package lock next time I work on this so we can see if some stuff isn't being upgraded.

I think if I cleared everything and did an install on a new machine it would probably work (I'll try that), but I'm more concerned that the updating doesn't work. If there's a problem with updating I think we should pin it down, especially if it applied to more than just the terminal.

@UziTech
Copy link
Member

UziTech commented Jan 29, 2021

@jeff-hykin is this still a problem?

@jeff-hykin
Copy link
Contributor Author

Haven't checked but we can close this and I'll post a message if I find it still a problem later

@github-actions
Copy link

github-actions bot commented May 3, 2021

🎉 This issue has been resolved in version 13.0.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report 🐛 When something isn't working released unable to duplicate !! When the issue cannot be duplicated
Development

Successfully merging a pull request may close this issue.

3 participants