Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settings getting cleared when updating them using API #47763

Open
tsalinger opened this issue Apr 12, 2018 · 8 comments
Open

Settings getting cleared when updating them using API #47763

tsalinger opened this issue Apr 12, 2018 · 8 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug config VS Code configuration, set up issues
Milestone

Comments

@tsalinger
Copy link
Contributor

tsalinger commented Apr 12, 2018

Issue Type: Bug

  1. Create an extension with 'yo code' and paste in the code at the end of this issue
  2. Switch to a light theme.
  3. Activate the extension and CTRL+Tab multiple times to another open file in the project while the settings are being imported.
  4. Notice how the user settings are temporarily lost and the dark theme is used again, although the users settings still show the light theme.

Observations:
The accessibilitySupport prompt popups shortly before it switches to the dark theme
Sometimes only a restart of VS Code gets the light theme back.

settingslostwhileimporting

dark_theme_during_settings_import

'use strict';

import * as vscode from 'vscode';

export function activate(context: vscode.ExtensionContext) {
    let disposable = vscode.commands.registerCommand('extension.importSettings', () => {
        const config: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration();
        Object.keys(settings).forEach(key => {
            config.update(key, settings[key], vscode.ConfigurationTarget.Global)
        })
    });

    context.subscriptions.push(disposable);
}

export function deactivate() {
}


var settings: { [s: string]: any; } = {
    "files.autoSave": "off",
    "editor.fontSize": 14,
    "editor.fontFamily": "Consolas, 'Courier New', monospace",
    "editor.tabSize": 4,
    "editor.renderWhitespace": "none",
    "editor.cursorStyle": "line",
    "editor.multiCursorModifier": "alt",
    "editor.insertSpaces": true,
    "editor.wordWrap": "off",
    "diffEditor.ignoreTrimWhitespace": true,
    "diffEditor.renderIndicators": true,
    "diffEditor.renderSideBySide": true,
    "editor.acceptSuggestionOnCommitCharacter": true,
    "editor.acceptSuggestionOnEnter": "on",
    "editor.autoClosingBrackets": true,
    "editor.autoIndent": true,
    "editor.codeLens": true,
    "editor.colorDecorators": true,
    "editor.cursorBlinking": "blink",
    "editor.cursorWidth": 0,
    "editor.detectIndentation": true,
    "editor.dragAndDrop": true,
    "editor.emptySelectionClipboard": true,
    "editor.find.autoFindInSelection": false,
    "editor.find.seedSearchStringFromSelection": true,
    "editor.folding": true,
    "editor.foldingStrategy": "auto",
    "editor.fontLigatures": false,
    "editor.fontWeight": "normal",
    "editor.formatOnPaste": false,
    "editor.formatOnSave": false,
    "editor.formatOnSaveTimeout": 750,
    "editor.formatOnType": false,
    "editor.glyphMargin": true,
    "editor.hideCursorInOverviewRuler": false,
    "editor.letterSpacing": 0,
    "editor.lightbulb.enabled": true,
    "editor.lineHeight": 0,
    "editor.lineNumbers": "on",
    "editor.links": true,
    "editor.matchBrackets": true,
    "editor.minimap.enabled": true,
    "editor.minimap.maxColumn": 120,
    "editor.minimap.renderCharacters": true,
    "editor.minimap.showSlider": "mouseover",
    "editor.minimap.side": "right",
    "editor.mouseWheelScrollSensitivity": 1,
    "editor.mouseWheelZoom": false,
    "editor.occurrencesHighlight": true,
    "editor.overviewRulerBorder": true,
    "editor.overviewRulerLanes": 3,
    "editor.parameterHints": true,
    "editor.quickSuggestionsDelay": 10,
    "editor.renderControlCharacters": false,
    "editor.renderIndentGuides": true,
    "editor.renderLineHighlight": "line",
    "editor.roundedSelection": true,
    "editor.rulers": [],
    "editor.scrollBeyondLastLine": true,
    "editor.selectionHighlight": true,
    "editor.showFoldingControls": "mouseover",
    "editor.smoothScrolling": false,
    "editor.snippetSuggestions": "inline",
    "editor.stablePeek": false,
    "editor.suggestFontSize": 0,
    "editor.suggestLineHeight": 0,
    "editor.suggestOnTriggerCharacters": true,
    "editor.suggestSelection": "recentlyUsed",
    "editor.tabCompletion": false,
    "editor.tokenColorCustomizations": {},
    "editor.trimAutoWhitespace": true,
    "editor.useTabStops": true,
    "editor.wordBasedSuggestions": true,
    "editor.wordSeparators": "`~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?",
    "editor.wordWrapColumn": 80,
    "editor.wrappingIndent": "same",
    "javascript.format.enable": true,
    "javascript.format.insertSpaceAfterCommaDelimiter": true,
    "javascript.format.insertSpaceAfterConstructor": false,
    "javascript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": true,
    "javascript.format.insertSpaceAfterKeywordsInControlFlowStatements": true,
    "javascript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false,
    "javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true,
    "javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
    "javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
    "javascript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
    "javascript.format.insertSpaceAfterSemicolonInForStatements": true,
    "javascript.format.insertSpaceBeforeAndAfterBinaryOperators": true,
    "javascript.format.insertSpaceBeforeFunctionParenthesis": false,
    "javascript.format.placeOpenBraceOnNewLineForControlBlocks": false,
    "javascript.format.placeOpenBraceOnNewLineForFunctions": false,
    "javascript.implicitProjectConfig.checkJs": false,
    "javascript.implicitProjectConfig.experimentalDecorators": false,
    "javascript.nameSuggestions": true,
    "javascript.referencesCodeLens.enabled": false,
    "javascript.suggestionActions.enabled": true,
    "javascript.validate.enable": true,
    "jsDocCompletion.enabled": true,
    "typescript.autoImportSuggestions.enabled": true,
    "typescript.check.npmIsInstalled": true,
    "typescript.disableAutomaticTypeAcquisition": false,
    "typescript.experimental.syntaxFolding": true,
    "typescript.format.enable": true,
    "typescript.format.insertSpaceAfterCommaDelimiter": true,
    "typescript.format.insertSpaceAfterConstructor": false,
    "typescript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": true,
    "typescript.format.insertSpaceAfterKeywordsInControlFlowStatements": true,
    "typescript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false,
    "typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true,
    "typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
    "typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
    "typescript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
    "typescript.format.insertSpaceAfterSemicolonInForStatements": true,
    "typescript.format.insertSpaceAfterTypeAssertion": false,
    "typescript.format.insertSpaceBeforeAndAfterBinaryOperators": true,
    "typescript.format.insertSpaceBeforeFunctionParenthesis": false,
    "typescript.format.placeOpenBraceOnNewLineForControlBlocks": false,
    "typescript.format.placeOpenBraceOnNewLineForFunctions": false,
    "typescript.implementationsCodeLens.enabled": false,
    "typescript.locale": null,
    "typescript.npm": null,
    "typescript.quickSuggestionsForPaths": true,
    "typescript.referencesCodeLens.enabled": false,
    "typescript.reportStyleChecksAsWarnings": true,
    "typescript.suggestionActions.enabled": true,
    "typescript.tsc.autoDetect": "on",
    "typescript.tsdk": null,
    "typescript.tsserver.log": "off",
    "typescript.tsserver.pluginPaths": [],
    "typescript.tsserver.trace": "off",
    "typescript.useCodeSnippetsOnMethodSuggest": false,
    "typescript.validate.enable": true
}

VS Code version: Code - Insiders 1.23.0-insider (fe9d953, 2018-04-12T05:17:00.120Z)
OS version: Windows_NT x64 10.0.16299

System Info
Item Value
CPUs Intel(R) Core(TM) i7-4600U CPU @ 2.10GHz (4 x 2694)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: disabled_software
video_decode: enabled
video_encode: enabled
vpx_decode: unavailable_software
webgl: enabled
webgl2: enabled
Memory (System) 7.88GB (3.95GB free)
Process Argv C:\Program Files\Microsoft VS Code Insiders\Code - Insiders.exe
Screen Reader yes
VM 0%
Extensions (13)
Extension Author (truncated) Version
vscode-css-formatter aes 1.0.1
numbered-bookmarks ale 0.11.1
regex chr 0.1.0
vscode-eslint dba 1.4.8
gitlens eam 8.2.1
tslint eg2 1.0.28
vsc-material-theme Equ 1.5.1
python ms- 2018.3.1
debugger-for-chrome msj 4.3.0
gitlink qez 0.4.2
ayu tea 0.14.0
vscode-todo-highlight way 0.5.12
markdown-pdf yza 0.1.8

(3 theme extensions excluded)

@tsalinger tsalinger added the bug Issue identified by VS Code Team member as probable bug label Apr 12, 2018
@sandy081 sandy081 added this to the April 2018 milestone Apr 13, 2018
@sandy081 sandy081 added the config VS Code configuration, set up issues label Apr 13, 2018
@sandy081
Copy link
Member

@tsalinger I am not able to reproduce this on insiders also when running from dev. Can you please try disabling extensions?

@sandy081 sandy081 added info-needed Issue requires more information from poster and removed bug Issue identified by VS Code Team member as probable bug labels Apr 19, 2018
@tsalinger
Copy link
Contributor Author

@sandy081 I can still reproduce this in the latest insiders with all extensions disabled.
Maybe the key is to have the following user settings to start from:

{
    "editor.accessibilitySupport": "off",
    "files.autoSave": "onWindowChange",
    "workbench.colorTheme": "Default Light+",
}

Also make sure to use "files.autoSave": "onWindowChange" in the settings arrray.

The bug seems to appear less frequently when the VS Code window is not maximized.

@sandy081
Copy link
Member

@tsalinger No luck. May be I will sit with you tomorrow and look into it on your machine

@sandy081 sandy081 modified the milestones: April 2018, May 2018 Apr 23, 2018
@sandy081 sandy081 added bug Issue identified by VS Code Team member as probable bug and removed info-needed Issue requires more information from poster labels Apr 23, 2018
@usernamehw
Copy link
Contributor

I've seen a somewhat similar issue. On a laptop it switches to the default dark theme (for about 10ms) and then back at random (cannot reproduce reliably).

There is a comment on a linked issue:

During the import process the settings might be reverted to an empty object for an instant. This leads to a flickering from a light theme to the default dark theme and back. Additionally, the 'screen-reader optimized' message box might be visible for an instant.

Does that mean that the reason of this flickering is some extension or a problem with settings file or API?

@sandy081
Copy link
Member

@usernamehw We investigated on this issue and found out that this is happening because of non-atomic nature of write and read. If a setting is being written into the file and the file is being read at the same time, read is returning empty contents. This can happen when multiple updates are happening.

@sandy081 sandy081 modified the milestones: May 2018, June 2018 May 22, 2018
@sandy081 sandy081 modified the milestones: June 2018, July 2018 Jun 25, 2018
@sandy081 sandy081 added the debt Code quality issues label Jun 25, 2018
@sandy081 sandy081 modified the milestones: July 2018, September 2018 Jul 26, 2018
@sandy081 sandy081 modified the milestones: September 2018, October 2018 Sep 26, 2018
@sandy081 sandy081 modified the milestones: October 2018, November 2018 Oct 29, 2018
@sandy081 sandy081 modified the milestones: November 2018, Backlog Dec 3, 2018
@sandy081 sandy081 removed the debt Code quality issues label Mar 6, 2019
@sandy081 sandy081 modified the milestones: Backlog, April 2019 Mar 25, 2019
@sandy081 sandy081 modified the milestones: April 2019, May 2019 Apr 29, 2019
@sandy081 sandy081 modified the milestones: May 2019, June 2019 May 31, 2019
@sandy081 sandy081 modified the milestones: June 2019, July 2019 Jun 25, 2019
@sandy081 sandy081 modified the milestones: July 2019, Backlog Jul 22, 2019
@sandy081 sandy081 changed the title Bug: Switching to dark theme during user settings update Settings getting cleared when updating them using API Jun 9, 2020
@bcroq
Copy link

bcroq commented Nov 10, 2020

I just lost my user settings a few seconds after starting code 😞

VS Code version: 1.51.0 upgraded 4 days ago
OS version: Ubuntu 20.04

@jaredcwhite
Copy link

I've seen this multiple times now via background software updates. Grabbing my settings.json from backup for the third time… :'(

(yes I should probably turn on Settings Sync, but IMHO that's not an adequate solution to this problem…)

@sandy081
Copy link
Member

Noted, I have added some fixes recently which might prevent this. Can you please try with our recent insiders and see if you see this issue yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug config VS Code configuration, set up issues
Projects
None yet
Development

No branches or pull requests

5 participants