8000 Feature/oni sessions by akinsho · Pull Request #2479 · onivim/oni · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Apr 1, 2020. It is now read-only.

Feature/oni sessions #2479

Merged
merged 58 commits into from
Aug 22, 2018
Merged

Feature/oni sessions #2479

merged 58 commits into from
Aug 22, 2018

Conversation

akinsho
Copy link
Member
@akinsho akinsho commented Jul 30, 2018

Finally had a go at implementing this after the conversation on discord a while ago re. suggested implementation @bryphe (hopefully this is in line with what you wanted) re. multiplexing and putting the methods on the oni editor.

Currently this adds a side bar pane with a list of available sessions these are saved to a default directory HOME/.config/oni/sessions under the name a user inputs as a vim file. Selecting the input option adds an input which is the name we use for the session.

The list is gotten by reading the dir and getting all the files saved and on selecting one it call so ${session.file}

Outstanding

  • Flags and configurability
  • Fix vim navigator focus bug
  • improve ui
  • delete sessions
  • set current session and auto update it

@akinsho akinsho changed the title Feature/oni sessions [WIP] Feature/oni sessions Jul 30, 2018
@codecov
Copy link
codecov bot commented Jul 30, 2018

Codecov Report

Merging #2479 into master will decrease coverage by 0.66%.
The diff coverage is 49.13%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #2479      +/-   ##
=========================================
- Coverage   44.26%   43.6%   -0.67%     
=========================================
  Files         345     351       +6     
  Lines       13933   14176     +243     
  Branches     1829    1845      +16     
=========================================
+ Hits         6168    6181      +13     
- Misses       7525    7758     +233     
+ Partials      240     237       -3
Impacted Files Coverage Δ
ui-tests/mocks/Sidebar.ts 100% <ø> (ø) ⬆️
...src/Services/Configuration/DefaultConfiguration.ts 87.5% <ø> (ø) ⬆️
browser/src/Input/KeyBindings.ts 1.86% <0%> (-0.04%) ⬇️
browser/src/PersistentStore.ts 30.43% <0%> (-2.9%) ⬇️
browser/src/App.ts 8.98% <0%> (-4.46%) ⬇️
browser/src/neovim/NeovimInstance.ts 5.55% <0%> (-6.98%) ⬇️
browser/src/Editor/NeovimEditor/NeovimEditor.tsx 9.09% <0%> (-0.28%) ⬇️
...src/Services/VersionControl/VersionControlView.tsx 73.01% <100%> (ø) ⬆️
...rowser/src/UI/components/VersionControl/Staged.tsx 96.15% <100%> (ø) ⬆️
...owser/src/UI/components/VersionControl/Commits.tsx 94.11% <100%> (ø) ⬆️
... and 38 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2fd82f3...f68b061. Read the comment docs.

}

public get sessionsDir() {
return path.join(getUserHome(), ".config", "oni", "sessions")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you'll want to use getUserConfigFolderPath here, which gets the oni folder directly.

On Windows the oni folder is in %APPDATA%\oni versus ~/.config/oni.
May also help testing.

export const getUserConfigFolderPath = (): string => {
const configFileFromEnv = process.env["ONI_CONFIG_FILE"] as string // tslint:disable-line
Log.info("$env:ONI_CONFIG_FILE: " + configFileFromEnv)
if (configFileFromEnv) {
const configDir = path.dirname(configFileFromEnv)
Log.info("getUserConfigFolderPath - path overridden by environment variable: " + configDir)
return configDir
}
return Platform.isWindows()
? path.join(Platform.getUserHome(), "oni")
: path.join(Platform.getUserHome(), ".config/oni") // XDG-compliant
}

@TalAmuyal
Copy link
Collaborator
TalAmuyal commented Jul 30, 2018 via email

@akinsho akinsho changed the title [WIP] Feature/oni sessions Feature/oni sessions Aug 21, 2018
@akinsho
Copy link
Member Author
akinsho commented Aug 21, 2018

@CrossR @TalAmuyal would appreciate a review on this as I think its ready to go now.
The functionality is intentionally pretty minimal at this stage, its essentially a wrapper around calling mksession and source session, session files default to being saved in ~/config/oni/sessions/ but can be configured. Its under an experimental flag by default also.

Copy link
Member
@CrossR CrossR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given it a quick test, not 100% on the features added so this is what I've tested:

  • Opening a few files in splits/tabs, saving a session.
  • Restoring a session.
  • Changing the splits/tabs about, and the restoring again to check its saved.
  • Deleting saved sessions.

I'm getting some weirdness, ie I'll close with a single tab and open with 2 tabs of a file, but that doesn't seem to be an Oni issue, more the session file has 2 calls to tabedit for whatever reason.... I'm a bit of a sessions noob so who knows. The Oni side works great, its more me not quite getting the nvim side.

One thing I did notice is that it seems to constantly save, is that intended? I would have assumed it would only save after some changes are made, or the cursor moves etc, but it seems to save constantly when the cursor is in the buffer? If that's default behaviour, just ignore me.

For a later PR, bringing over the undo feature would be nice, or a confirmation of delete (or both), but thats just for a later PR.

@akinsho
Copy link
Member Author
akinsho commented Aug 21, 2018

@CrossR thanks for the review 👍 ✨,
Re. functionality thats actually all it does for the time being 😆, it relies heavily on the sessiopts that a user has set so things like what tabs are where etc. all come from a users init.vim seemed the cleanest way for a vim user though for new users of vim it might eventually need some sort of default setting for sessionopts if neovim doesn't already have sensible defaults I've no idea what is set by default.

re saving all the time, its debounced 200ms and tbh listens to the bufenter event so shouldn't be calling mksession unless you are entering a buffer, when you say constantly save what was happening? calls to mkession in the console?

@CrossR
Copy link
Member
CrossR commented Aug 21, 2018

re saving all the time, its debounced 200ms and tbh listens to the bufenter event so shouldn't be calling mksession unless you are entering a buffer, when you say constantly save what was happening? calls to mkession in the console?

If I sit with the cursor in the buffer and the sidebar opened, I see the "Last modified" never changes from 0 seconds, and if I watch the file in the sessions folder, I can see the modified time changing even if I'm not moving or doing anything in the buffer, other than just having the cursor sat there in normal mode.

@akinsho
Copy link
Member Author
akinsho commented Aug 21, 2018

Ahh that's a result of the way that I render the time string which I guess can be confusing basically the time shown is the time since it was last modified so basically if its a very recent change say a completely new session then it will say last modified 10s then 15s as time goes on.

The idea was that you could see at a glance the last time you used a session so if one is months old you might think to delete it, wasn't strictly necessary just something I though would be nice to have, the actual time is static a prev. commit had it rendering as a full date string but it just seemed a bit less useful since the core info I was trying to convey was how recently it was used

@akinsho
Copy link
Member Author
akinsho commented Aug 21, 2018

Actually just re-read your comment if the file in the filesystem is changing its modified time every second thats not intended but if oni is getting and losing focus repeatedly that would trigger a bufEnter, I just had a look at the dir locally and all the session files have the right mtime's none are changing until I switch buffers around 😕

@akinsho
Copy link
Member Author
akinsho commented Aug 22, 2018

Going to merge this now and can keep an eye on how often the session is being saved and see if I can reproduce the constant save issue.

@akinsho akinsho merged commit e3f65e6 into onivim:master Aug 22, 2018
@feltech
Copy link
Contributor
feltech commented Aug 24, 2018

I had a go at enabling this. Previously I had been using vim-session, but that is rather glitchy in Oni.

Unfortunately I found with Oni's session support enabled I seemed to randomly lose unsaved work. I would look away for a minute or two, then when I came back the text had reverted to what's saved on disk.

I haven't had a chance to look into it further. I'm using Oni as my main code editor at work (in python), so can't spend much time trying to debug it here.

@akinsho
Copy link
Member Author
akinsho commented Aug 24, 2018

@feltech thanks or trying out the functionality 👍, you are right I've noted the issue but havent had time to log it properly, it probably relates to what @CrossR was noticing re. the updating not sure what or how or whats going on but will debug once i get a chance

@akinsho
Copy link
Member Author
akinsho commented Aug 28, 2018

Hmm seems the bug here persists with this PR disabled so might actually be due to something else 😭, not sure what would cause a buffer to revert to an earlier version maybe a change thats affecting the prettier autoformatting on save 😕

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0