Skip to content

Conversation

@mikejoseph23
Copy link

Fixes #30

Feature Description

Adds a new startup option that allows MarkText to automatically open the last folder that was opened in the previous session.

Use Case

Many users work with the same folder/project repeatedly across multiple MarkText sessions. This feature eliminates the need to manually navigate and open the same folder every time MarkText starts.

Implementation

New Startup Option: "Open last opened folder"

  • Added to Preferences → General → Startup
  • Stored as lastOpenedFolder in preferences
  • Updated whenever a user opens a new folder via openDirectory()
  • On startup, automatically opens the last folder if this option is selected

Files Changed

  • src/main/app/index.js - Added startup logic for last folder
  • src/main/preferences/schema.json - Added preference definitions
  • src/main/windows/editor.js - Save last opened folder on directory open
  • src/renderer/src/prefComponents/general/index.vue - Added UI toggle
  • src/renderer/src/store/preferences.js - Added preference state
  • static/locales/*.json - Added i18n strings for all languages
  • static/preference.json - Added default preference

Testing

Tested on macOS:

  • Opening various folders updates the last opened folder correctly
  • Restarting with the option enabled opens the last folder automatically
  • Option can be toggled on/off in preferences

Benefits

  • Faster workflow for project-based work
  • Consistent with behavior in other editors
  • Optional - doesn't affect users who prefer other startup modes

This commit adds a new startup action "openLastFolder" that allows
MarkText to automatically open the last folder that was opened when
the application starts.

Changes:
- Added `lastOpenedFolder` preference to track the most recently opened folder
- Added `openLastFolder` to the `startUpAction` enum in preferences schema
- Updated UI to show new "Open last opened folder" radio option in General preferences
- Added i18n translations for all supported languages (en, zh-CN, zh-TW, ja, ko, fr, de, es, pt)
- Implemented folder tracking logic in app initialization and folder open handlers
- Added startup logic to restore last opened folder when selected

The last opened folder is automatically tracked whenever:
- A folder is opened via the File menu or keyboard shortcut
- A folder is opened via command line or file system
- A folder is opened in an existing window
- Add lastOpenedFolder to default preference.json to ensure persistence
- Add display: block to radio buttons for proper vertical layout
- Ensures "Open blank page" appears below "Open last opened folder"

Fixes issue where lastOpenedFolder wasn't being saved to preferences
and radio buttons were appearing on the same line.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Add startup option to open last opened folder

1 participant