-
Notifications
You must be signed in to change notification settings - Fork 16
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
If file is already open, switch to it instead of opening it again #27
Comments
Not actually sure how to get current open files. I know it's contained in the |
This should be possible now with zyedidia/micro@cb45481 I'll look into it, but I encourage PR's as well :) |
I'd be interested in implementing this, but don't have time this week. If you get to it before me, that's great. If not, I'll post here when I start working on it so we don't duplicate our efforts. |
Here's a function to get the opened files indicies -- Check if the target abspath is already opened
local function find_open_file(tar_abspath)
-- What we return
local results = {
["tabs_i"] = nil,
["views_i"] = nil
}
-- Go through each tab
for i = 0, curTab do
-- Go through each view in the tab
-- Note that Views[0] is NEVER VALID
for x = 1, #tabs[i + 1].Views do
-- Seems to take one-based on its arrays, even though Go is zero-based
if tar_abspath == tabs[i + 1].Views[x].Buf.AbsPath then
results.tab_i = i + 1
results.view_i = x
return results
end
end
end
return results
end
but I'm kind of blanking on how to set the cursor to it. |
Note that until zyedidia/micro#1070 is fixed, an open file in a different tab will not be able to be detected with the above code. Once it's fixed, the only thing stopping this issue being closed is how to move the cursor to the target view. That might already be possible, but I haven't really looked for it yet. |
zyedidia/micro#1154 may have made this possible now, although I haven't checked. Ref zyedidia/micro#1070 (comment) |
If a file is already open, selecting it from the tree should switch focus to the pane that file is in, rather than opening it again in a new pane.
The text was updated successfully, but these errors were encountered: