Skip to content

Refactor: Extract session saving logic into private method#4

Draft
Copilot wants to merge 2 commits intofeat/session-save-restorefrom
copilot/sub-pr-1-another-one
Draft

Refactor: Extract session saving logic into private method#4
Copilot wants to merge 2 commits intofeat/session-save-restorefrom
copilot/sub-pr-1-another-one

Conversation

Copy link
Copy Markdown

Copilot AI commented Dec 20, 2025

Session saving logic was duplicated between _doOpenTab and removeFromOpenedFiles, creating maintenance burden and potential for inconsistencies.

Changes

  • Extracted _saveSession() private method: Encapsulates session persistence logic (preference check, file collection across editor windows, data center update)
  • Refactored call sites: Both _doOpenTab and removeFromOpenedFiles now delegate to _saveSession()

Before:

// Duplicated in both methods
const { restoreSession } = preferences.getAll()
if (restoreSession) {
  const allOpenedFiles = []
  const windowManager = _accessor.windowManager
  for (const window of windowManager.windows.values()) {
    if (window.type === 'editor') {
      allOpenedFiles.push(...window.openedFiles)
    }
  }
  dataCenter.setItem('lastSession', allOpenedFiles).then(...)
}

After:

this._saveSession()

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: walidsi <42148514+walidsi@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix session restore functionality based on feedback Refactor: Extract session saving logic into private method Dec 20, 2025
Copilot AI requested a review from walidsi December 20, 2025 20:44
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.

2 participants