microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.35k stars 28.91k forks source link

macOS: Add a setting to reopen last opened window after closing it #25811

Closed foo-baar closed 4 years ago

foo-baar commented 7 years ago

After updating to 1.11.2 I have been experiencing this issue that post restart of my Mac Sierra when I open code it start with an Untitled page.

Please let me know if any inputs are required on this ?

Danke, Vishal

kieferrm commented 7 years ago

@foo-baar What is the value of the following user setting: window.reopenFolders ?

foo-baar commented 7 years ago

Hello @kieferrm, here you go: screen shot 2017-05-04 at 9 51 48 am

kieferrm commented 7 years ago

@foo-baar can you please describe the full scenario. I.e. Do you have a folder open when you close vscode? Do you have files open? Are they saved or unsaved? How do you launch vscode (terminal or dock)?

foo-baar commented 7 years ago

It's a general working scenario: -> Working on a project, turned off vscode. -> Shut down Mac Air Sierra (System Version: macOS 10.12.4 (16E195) Kernel Version: Darwin 16.5.0)

-> Turn on machine again open vscode (launch from dock). -> Vscode shows an new\untitled 1 page.

Please let me know if I should do a video recording too (😋 just kidding). Danke.

bpasero commented 7 years ago

@foo-baar can you share the contents of your settings?

foo-baar commented 7 years ago

Hello @bpasero find it attached.

vscode.settings.docx l)

bpasero commented 7 years ago

@foo-baar if possible just copy and paste it into here

foo-baar commented 7 years ago

@bpasero :


  // Controls the font size in pixels.
  "editor.fontSize": 12,

  // Controls auto save of dirty files. Accepted values:  'off', 'afterDelay', 'onFocusChange' (editor loses focus), 'onWindowChange' (window loses focus). If set to 'afterDelay', you can configure the delay in 'files.autoSaveDelay'.
  "files.autoSave": "off",

  // Controls the font family.
  "editor.fontFamily": "Menlo, Monaco, 'Courier New', monospace",

  // The number of spaces a tab is equal to. This setting is overriden based on the file contents when `editor.detectIndentation` is on.
  "editor.tabSize": 4,

  // Controls how the editor should render whitespace characters, possibilities are 'none', 'boundary', and 'all'. The 'boundary' option does not render single spaces between words.
  "editor.renderWhitespace": "none",

  // Configure glob patterns for excluding files and folders.
  "files.exclude": {
    "**/.git": true,
    "**/.svn": true,
    "**/.hg": true,
    "**/CVS": true,
    "**/.DS_Store": true
  },

  // Controls the cursor style, accepted values are 'block', 'block-outline', 'line', 'line-thin', 'underline' and 'underline-thin'
  "editor.cursorStyle": "line",

  // Insert spaces when pressing Tab. This setting is overriden based on the file contents when `editor.detectIndentation` is on.
  "editor.insertSpaces": true,

  // Controls how lines should wrap. Can be:
  //  - 'off' (disable wrapping),
  //  - 'on' (viewport wrapping),
  //  - 'wordWrapColumn' (wrap at `editor.wordWrapColumn`) or
  //  - 'bounded' (wrap at minimum of viewport and `editor.wordWrapColumn`).
  "editor.wordWrap": "off",

  // Configure file associations to languages (e.g. "*.extension": "html"). These have precedence over the default associations of the languages installed.
  "files.associations": {}

}
,
{

  // Insert snippets when their prefix matches. Works best when 'quickSuggestions' aren't enabled.
  "editor.tabCompletion": false,

  // Controls the font family.
  "editor.fontFamily": "Menlo, Monaco, 'Courier New', monospace",

  // Controls the font weight.
  "editor.fontWeight": "normal",

  // Controls the font size in pixels.
  "editor.fontSize": 12,

  // Controls the line height. Use 0 to compute the lineHeight from the fontSize.
  "editor.lineHeight": 0,

  // Controls the display of line numbers. Possible values are 'on', 'off', and 'relative'. 'relative' shows the line count from the current cursor position.
  "editor.lineNumbers": "on",

  // Columns at which to show vertical rulers
  "editor.rulers": [],

  // Characters that will be used as word separators when doing word related navigations or operations
  "editor.wordSeparators": "`~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?",

  // The number of spaces a tab is equal to. This setting is overriden based on the file contents when `editor.detectIndentation` is on.
  "editor.tabSize": 4,

  // Insert spaces when pressing Tab. This setting is overriden based on the file contents when `editor.detectIndentation` is on.
  "editor.insertSpaces": true,

  // When opening a file, `editor.tabSize` and `editor.insertSpaces` will be detected based on the file contents.
  "editor.detectIndentation": true,

  // Controls if selections have rounded corners
  "editor.roundedSelection": true,

  // Controls if the editor will scroll beyond the last line
  "editor.scrollBeyondLastLine": true,

  // Controls if the minimap is shown
  "editor.minimap.enabled": false,

  // Render the actual characters on a line (as opposed to color blocks)
  "editor.minimap.renderCharacters": true,

  // Limit the width of the minimap to render at most a certain number of columns
  "editor.minimap.maxColumn": 120,

  // Controls how lines should wrap. Can be:
  //  - 'off' (disable wrapping),
  //  - 'on' (viewport wrapping),
  //  - 'wordWrapColumn' (wrap at `editor.wordWrapColumn`) or
  //  - 'bounded' (wrap at minimum of viewport and `editor.wordWrapColumn`).
  "editor.wordWrap": "off",

  // Controls the wrapping column of the editor when `editor.wordWrap` is 'wordWrapColumn' or 'bounded'.
  "editor.wordWrapColumn": 80,

  // Controls the indentation of wrapped lines. Can be one of 'none', 'same' or 'indent'.
  "editor.wrappingIndent": "same",

  // A multiplier to be used on the `deltaX` and `deltaY` of mouse wheel scroll events
  "editor.mouseWheelScrollSensitivity": 1,

  // Controls if suggestions should automatically show up while typing
  "editor.quickSuggestions": {
    "other": true,
    "comments": false,
    "strings": false
  },

  // Controls the delay in ms after which quick suggestions will show up
  "editor.quickSuggestionsDelay": 10,

  // Enables parameter hints
  "editor.parameterHints": true,

  // Controls if the editor should automatically close brackets after opening them
  "editor.autoClosingBrackets": true,

  // Controls if the editor should automatically format the line after typing
  "editor.formatOnType": false,

  // Controls if the editor should automatically format the pasted content. A formatter must be available and the formatter should be able to format a range in a document.
  "editor.formatOnPaste": false,

  // Controls if suggestions should automatically show up when typing trigger characters
  "editor.suggestOnTriggerCharacters": true,

  // Controls if suggestions should be accepted on 'Enter' - in addition to 'Tab'. Helps to avoid ambiguity between inserting new lines or accepting suggestions.
  "editor.acceptSuggestionOnEnter": true,

  // Controls if suggestions should be accepted on commit characters. For instance in JavaScript the semi-colon (';') can be a commit character that accepts a suggestion and types that character.
  "editor.acceptSuggestionOnCommitCharacter": true,

  // Controls whether snippets are shown with other suggestions and how they are sorted.
  "editor.snippetSuggestions": "bottom",

  // Controls whether copying without a selection copies the current line.
  "editor.emptySelectionClipboard": true,

  // Controls whether completions should be computed based on words in the document.
  "editor.wordBasedSuggestions": true,

  // Font size for the suggest widget
  "editor.suggestFontSize": 0,

  // Line height for the suggest widget
  "editor.suggestLineHeight": 0,

  // Controls whether the editor should highlight similar matches to the selection
  "editor.selectionHighlight": true,

  // Controls whether the editor should highlight semantic symbol occurrences
  "editor.occurrencesHighlight": true,

  // Controls the number of decorations that can show up at the same position in the overview ruler
  "editor.overviewRulerLanes": 3,

  // Controls if a border should be drawn around the overview ruler.
  "editor.overviewRulerBorder": true,

  // Control the cursor animation style, possible values are 'blink', 'smooth', 'phase', 'expand' and 'solid'
  "editor.cursorBlinking": "blink",

  // Zoom the font of the editor when using mouse wheel and holding Ctrl
  "editor.mouseWheelZoom": false,

  // Controls the cursor style, accepted values are 'block', 'block-outline', 'line', 'line-thin', 'underline' and 'underline-thin'
  "editor.cursorStyle": "line",

  // Enables font ligatures
  "editor.fontLigatures": false,

  // Controls if the cursor should be hidden in the overview ruler.
  "editor.hideCursorInOverviewRuler": false,

  // Controls how the editor should render whitespace characters, possibilities are 'none', 'boundary', and 'all'. The 'boundary' option does not render single spaces between words.
  "editor.renderWhitespace": "none",

  // Controls whether the editor should render control characters
  "editor.renderControlCharacters": false,

  // Controls whether the editor should render indent guides
  "editor.renderIndentGuides": false,

  // Controls how the editor should render the current line highlight, possibilities are 'none', 'gutter', 'line', and 'all'.
  "editor.renderLineHighlight": "line",

  // Controls if the editor shows code lenses
  "editor.codeLens": true,

  // Controls whether the editor has code folding enabled
  "editor.folding": true,

  // Highlight matching brackets when one of them is selected.
  "editor.matchBrackets": true,

  // Controls whether the editor should render the vertical glyph margin. Glyph margin is mostly used for debugging.
  "editor.glyphMargin": true,

  // Inserting and deleting whitespace follows tab stops
  "editor.useTabStops": true,

  // Remove trailing auto inserted whitespace
  "editor.trimAutoWhitespace": true,

  // Keep peek editors open even when double clicking their content or when hitting Escape.
  "editor.stablePeek": false,

  // Controls if the editor should allow to move selections via drag and drop.
  "editor.dragAndDrop": false,

  // Controls if the diff editor shows the diff side by side or inline
  "diffEditor.renderSideBySide": true,

  // Controls if the diff editor shows changes in leading or trailing whitespace as diffs
  "diffEditor.ignoreTrimWhitespace": true,

  // Controls if the diff editor shows +/- indicators for added/removed changes
  "diffEditor.renderIndicators": true,

  // Format a file on save. A formatter must be available, the file must not be auto-saved, and editor must not be shutting down.
  "editor.formatOnSave": false,

  // When enabled, emmet abbreviations are expanded when pressing TAB.
  "emmet.triggerExpansionOnTab": true,

  // Preferences used to modify behavior of some actions and resolvers of Emmet.
  "emmet.preferences": {},

  // Define profile for specified syntax or use your own profile with specific rules.
  "emmet.syntaxProfiles": {},

  // An array of languages where emmet abbreviations should not be expanded.
  "emmet.excludeLanguages": [
    "markdown"
  ],

  // Path to a folder containing emmet profiles, snippets and preferences
  "emmet.extensionsPath": null,

  // Controls if opened editors should show in tabs or not.
  "workbench.editor.showTabs": true,

  // Controls the position of the editor's tabs close buttons or disables them when set to 'off'.
  "workbench.editor.tabCloseButton": "right",

  // Controls if opened editors should show with an icon or not. This requires an icon theme to be enabled as well.
  "workbench.editor.showIcons": true,

  // Controls if opened editors show as preview. Preview editors are reused until they are kept (e.g. via double click or editing).
  "workbench.editor.enablePreview": true,

  // Controls if opened editors from Quick Open show as preview. Preview editors are reused until they are kept (e.g. via double click or editing).
  "workbench.editor.enablePreviewFromQuickOpen": true,

  // Controls where editors open. Select 'left' or 'right' to open editors to the left or right of the current active one. Select 'first' or 'last' to open editors independently from the currently active one.
  "workbench.editor.openPositioning": "right",

  // Controls if an editor is revealed in any of the visible groups if opened. If disabled, an editor will prefer to open in the currently active editor group. If enabled, an already opened editor will be revealed instead of opened again in the currently active editor group. Note that there are some cases where this setting is ignored, e.g. when forcing an editor to open in a specific group or to the side of the currently active group.
  "workbench.editor.revealIfOpen": false,

  // Controls if Quick Open should close automatically once it loses focus.
  "workbench.quickOpen.closeOnFocusLost": true,

  // Controls if opening settings also opens an editor showing all default settings.
  "workbench.settings.openDefaultSettings": true,

  // Controls the location of the sidebar. It can either show on the left or right of the workbench.
  "workbench.sideBar.location": "left",

  // Controls the visibility of the status bar at the bottom of the workbench.
  "workbench.statusBar.visible": true,

  // Controls the visibility of the activity bar in the workbench.
  "workbench.activityBar.visible": true,

  // Controls if editors showing a file should close automatically when the file is deleted or renamed by some other process. Disabling this will keep the editor open as dirty on such an event. Note that deleting from within the application will always close the editor and that dirty files will never close to preserve your data.
  "workbench.editor.closeOnFileDelete": true,

  // Navigate between open files using three-finger swipe horizontally.
  "workbench.editor.swipeToNavigate": false,

  // When enabled, will show the watermark tips when no editor is open.
  "workbench.tips.enabled": true,

  // When enabled, will show the Welcome page on startup.
  "workbench.welcome.enabled": true,

  // Specifies the color theme used in the workbench.
  "workbench.colorTheme": "Default Dark+",

  // Specifies the icon theme used in the workbench.
  "workbench.iconTheme": null,

  // Overrides colors from the currently selected color theme.
  "workbench.colorCustomizations": {},

  // Controls if files should open in a new window.
  // - default: files will open in the window with the files' folder open or the last active window unless opened via the dock or from finder (macOS only)
  // - on: files will open in a new window
  // - off: files will open in the window with the files' folder open or the last active window
  // Note that there can still be cases where this setting is ignored (e.g. when using the -new-window or -reuse-window command line option).
  "window.openFilesInNewWindow": "default",

  // Controls if folders should open in a new window or replace the last active window.
  // - default: folders will open in a new window unless a folder is picked from within the application (e.g. via the File menu)
  // - on: folders will open in a new window
  // - off: folders will replace the last active window
  // Note that there can still be cases where this setting is ignored (e.g. when using the -new-window or -reuse-window command line option).
  "window.openFoldersInNewWindow": "default",

  // Controls how folders are being reopened after a restart. Select 'none' to never reopen a folder, 'one' to reopen the last folder you worked on or 'all' to reopen all folders of your last session.
  "window.reopenFolders": "one",

  // Controls if a window should restore to full screen mode if it was exited in full screen mode.
  "window.restoreFullscreen": false,

  // Adjust the zoom level of the window. The original size is 0 and each increment above (e.g. 1) or below (e.g. -1) represents zooming 20% larger or smaller. You can also enter decimals to adjust the zoom level with a finer granularity.
  "window.zoomLevel": 0,

  // Controls the window title based on the active editor. Variables are substituted based on the context:
  // ${activeEditorShort}: e.g. myFile.txt
  // ${activeEditorMedium}: e.g. myFolder/myFile.txt
  // ${activeEditorLong}: e.g. /Users/Development/myProject/myFolder/myFile.txt
  // ${rootName}: e.g. myProject
  // ${rootPath}: e.g. /Users/Development/myProject
  // ${appName}: e.g. VS Code
  // ${dirty}: a dirty indicator if the active editor is dirty
  // ${separator}: a conditional separator (" - ") that only shows when surrounded by variables with values
  "window.title": "${activeEditorShort}${separator}${rootName}",

  // Controls the dimensions of opening a new window. By default, a new window will open in the center of the screen with small dimensions. When set to  'inherit', the window will get the same dimensions as the last active one. When set to 'maximized', the window will open maximized and fullscreen if configured to 'fullscreen'.
  "window.newWindowDimensions": "default",
bpasero commented 7 years ago

@foo-baar thanks, these seem to be the default settings, but did you change any? The contents are showing on the right hand side when you open settings:

image

foo-baar commented 7 years ago
@bpasero : USER SETTINGS = 
// Place your settings in this file to overwrite the default settings
{
    "window.zoomLevel": 0,
    "editor.fontSize": 14,
    "files.autoSave": "afterDelay",
    "editor.renderWhitespace": "boundary",
    "terminal.integrated.fontSize": 14,
    "update.channel":"default",
    "workbench.iconTheme": "vscode-icons",
    "workbench.colorTheme": "Atom One Dark",
    "editor.wordWrap": "off",
    "workbench.welcome.enabled": false
}

Workspace setting:
// Place your settings in this file to overwrite default and user settings.
{
    "files.exclude": {
        "**/.git": true,
        "**/.DS_Store": true
    }, 
    // Controls auto save of dirty files. Accepted values:  "off", "afterDelay", "onFocusChange". If set to "afterDelay" you can configure the delay in "files.autoSaveDelay".
    "files.autoSave": "afterDelay",
    "vsicons.presets.angular": true
}
bpasero commented 7 years ago

@foo-baar does this reproduce for you when you just close VS Code and then start again? Do you really need to restart your OS to get this issue?

foo-baar commented 7 years ago

Hey @bpasero, right, so I tried to analyse the scenario in past few days, and here it is:

a. Working on some project, close vscode by pressing cmd+Q, open vscode again and it remember the last opened project.

b. Working on some project, close vscode by pressing CLOSE button on window (red icon on top left corner), open vscode again and it show untitled-1 page.

Behaviour stays the when you restart Mac.

Do let me know if you have any query on this.

Danke.

bpasero commented 7 years ago

@foo-baar closing the window and then restarting we open up empty, this is expected and works as designed. Thanks for clarifying. I will update this issue.

foo-baar commented 7 years ago

@bpasero "closing the window and then restarting we open up empty" I don't think I understand the statement ? I am not closing the project, rather closing the vscode window.

bpasero commented 7 years ago

@foo-baar you are on macOS right?

foo-baar commented 7 years ago

yup

bpasero commented 7 years ago

@foo-baar there is a difference on macOS between quitting the app and closing the window:

Does that make sense?

foo-baar commented 7 years ago

@bpasero From my perspective the behaviour should be consistent irrespective to method user chose to close vscode. But if thats what majority on team decided than should be it.

Thanks once again for following up.

bpasero commented 7 years ago

@foo-baar I am not saying we as a team decide how it should be, we are just trying to follow macOS standard UX guidelines and I think in this case we found that it was more typical on macOS to not reopen a window when the user explicitly closed it (as opposed to quitting).

foo-baar commented 7 years ago

@bpasero Understand, makes sense too.

MikeSim1 commented 5 years ago

Any update on this? Driving me crazy. Closing the window with the application still "open" or running in the dock, and then reopening the window brings me to the default screen.

carina-akaia commented 4 years ago

@foo-baar I am not saying we as a team decide how it should be, we are just trying to follow macOS standard UX guidelines and I think in this case we found that it was more typical on macOS to not reopen a window when the user explicitly closed it (as opposed to quitting).

But it'll be better if users will have ability to configure that behavior

ankur-cp commented 3 years ago

I am dealing with this same issue. I am normally a Windows user, however I recently have been working in MacOS, and have found it pretty annoying also. I can confirm the issue described above... fully quitting VSCode and then relaunching it restores my previous files to the view (previous workspace is restored, as expected).

However, if I use the 'red-X' button to "close" my current VSCode window (...which means the application is still running but no longer on my screen, for MacOS...), and then proceed to open VSCode again, I've lost my recent workspace and am greeted with the default welcome page. I would expect it to still open with my last open files.

tral commented 3 years ago

I also think that there at least should be an option to control that. Look at other different text editors (e.g. SubLime), they do restore tabs when you close it with red close button because it's simply user friendly and convenient.

Lefgk commented 2 years ago

still no option for this ?

MikeSim1 commented 2 years ago

Nope :)

realLiQ commented 2 years ago

Will there ever be a fix for that?

filipstev commented 2 years ago

What would be a workaround for this?

MikeSim1 commented 2 years ago

The only workaround currently is to right click the dock icon or use the top menu to quit the application instead of using the red X on the window. On Jun 4, 2022, 6:52 PM -0400, Phillip @.***>, wrote:

What would be a workaround for this? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

filipstev commented 2 years ago

The only workaround currently is to right click the dock icon or use the top menu to quit the application instead of using the red X on the window. … On Jun 4, 2022, 6:52 PM -0400, Phillip @.>, wrote: What would be a workaround for this? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.>

Thanks! I've found that it's quicker to do CMD + Q, but hopefully we'll get an option to preserve it when clicking the red X 😅

realLiQ commented 2 years ago

The only workaround currently is to right click the dock icon or use the top menu to quit the application instead of using the red X on the window.

…

On Jun 4, 2022, 6:52 PM -0400, Phillip @.>, wrote: What would be a workaround for this? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.>

Thanks! I've found that it's quicker to do CMD + Q, but hopefully we'll get an option to preserve it when clicking the red X 😅

Hopefully...

inzmamulhassan commented 1 year ago

Hahahaha this issue was driving me crazy in 2023, that quit and reopen thing is very confusing. There should atleast be option or setting to change that.

javierguzman commented 1 year ago

Hello @bpasero! Is there a way to tell vscode to quit when all vscode windows have been closed or something like that? Similar to what iTerm has. Thank you in advance and regards

bpasero commented 1 year ago

No, but you can open a feature request for this, I think such a setting makes sense for those coming from Windows/Linux.

chriswydra commented 10 months ago

Can this please be re-opened? (not sure why it was closed?)

Need this badly - it is very jarring/annoying to close a workspace window (but not quit the app) and then when you reactivate vscode, are presented with a blank window, and have to then have to find and re-open the workspace you had open, rather than just being able to continue where you left off.

I'd recommend adding a (MacOS specific) preference e.g. "Reopen last opened workspace/folder when activating".

Note that "activating" is distinctly different from "opening" on a mac, and for the record the existing settings seem to work well when opening - just not when activating.

divyanshxcode commented 2 months ago

This behaviour is similar to browsers, when multiple tabs are open in a browser window and that window is closed (using Cmd+W / red dot), reopening the app from the dock opens a new window with the home tab.

But, we can cycle through previous windows with "Cmd+Shift+T". I think this will solve the problem if it is added to VS Code. It will also not break the UNIX guidelines as @bpasero suggested.