-
Notifications
You must be signed in to change notification settings - Fork 300
Feature/oni sessions #2479
Feature/oni sessions #2479
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
} | ||
|
||
public get sessionsDir() { | ||
return path.join(getUserHome(), ".config", "oni", "sessions") |
There was a problem hiding this comment.
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.
oni/browser/src/Services/Configuration/UserConfiguration.ts
Lines 27 to 40 in e46c720
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 | |
} |
Looking forward to that feature!
…On Mon, Jul 30, 2018, 14:04 Ryan C ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In browser/src/Services/Sessions/SessionManager.ts
<#2479 (comment)>:
> + private _sidebarManager: SidebarManager,
+ private _commands: Commands.Api,
+ ) {
+ fs.ensureDirSync(this.sessionsDir)
+ this._sidebarManager.add(
+ "save",
+ new SessionsPane({ store: this._store, commands: this._commands }),
+ )
+ }
+
+ public get sessions() {
+ return this._store.getState().sessions
+ }
+
+ public get sessionsDir() {
+ return path.join(getUserHome(), ".config", "oni", "sessions")
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.
https://github.com/onivim/oni/blob/e46c720fc82f1466347016bc0916a8d744c94793/browser/src/Services/Configuration/UserConfiguration.ts#L27-L40
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2479 (review)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AE3IjShabgZSOL9gBGkMDrsCjqxMkU25ks5uLuhTgaJpZM4Vl52L>
.
|
move section title to general location add delete session functionality
fix delete session bug causing reappearances
remove need for instantiation, use done callback
a large refactor of all observables is going to be required to upgrade redux observable so seems counter productive to write tests that will need to be re-written entirely once that is done
render session sidebar item second
@CrossR @TalAmuyal would appreciate a review on this as I think its ready to go now. |
There was a problem hiding this 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.
@CrossR thanks for the review 👍 ✨, re saving all the time, its debounced 200ms and tbh listens to the bufenter event so shouldn't be calling |
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. |
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 |
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 😕 |
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. |
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. |
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 😕 |
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