question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ctags - Neither rebuildOnFileSave nor rebuildOnStart work

See original GitHub issue

Environment data

VS Code version: 1.20.1 Python Extension version: 2018.1.0 Python Version: 2.7.14 OS and version: MacOS 10.13.3

Actual behavior

${workspaceFolder}/.vscode/tags file is not updated when I save a python file nor if I restart VS Code.

Expected behavior

${workspaceFolder}/.vscode/tags file will be updated when I save a python file or restart VS Code.

Steps to reproduce:

  • Verify tags file doesn’t exist
  • Open a project with python files in VS Code and open a Python source file
  • Verify the tags file still doesn’t exist (rebuildOnStart hasn’t activated)
  • Make a change to the Python file and save
  • Verify the tags file still doesn’t exist (rebuildOnFileSave hasn’t activated)
  • Perform a global symbol search
  • The tags file has been created (this is only created if it doesn’t exist, if it already existed it isn’t updated with new symbols)
  • Add a new function definition to a Python file and save (rebuildOnFileSave hasn’t activated)
  • Perform a global symbol search for newly added symbol (this fails to find it)
  • Run ‘Python: Build Workspace Symbols’ (this updates tags file)
  • Perform a global symbol search for newly added symbol (this succeeds)

Logs

Output from Python output panel (only gets logged when I perform a global symbol search if the tags file doesn’t exist, or if I run the ‘Python: Build Workspace Symbols’ command.)

ctags --options=/XXXXX/.vscode/extensions/ms-python.python-2018.1.0/resources/ctagOptions --languages=Python --exclude=**/site-packages/** --exclude=.history -o /YYYYY/.vscode/tags .

Output from Console window (Help->Developer Tools menu) (I see this on VS Code startup.)

[Extension Host] Python Extension: Failed to get conda info from conda null
t.log @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:253

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:25
  • Comments:17 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
gregflynncommented, Apr 5, 2018

Yea been scratching my head as to why goto symbol was always a few lines off, I added the following keybinding as a workaround for me:

{
        "key": "ctrl+shift+r",
        "command": "python.buildWorkspaceSymbols"
    }
1reaction
karrtikrcommented, Nov 18, 2019

So it looks like python.workspaceSymbols.rebuildOnStart and python.workspaceSymbols.rebuildOnFileSave were never implemented at all 🤷‍♂️ They were just a no-op setting.

I also checked the original commit of the setting where the implementation was added, 6ef8f53275b3bceaceddb0da78357aaf8c7fdb71, and a few commits around it. None had the implementation.

Prescribed solution

For python.workspaceSymbols.rebuildOnStart, add these lines at the end of constructor in https://github.com/Microsoft/vscode-python/blob/edbd57ad3cbdb8685de5eabf7933a9ecd7607ae2/src/client/workspaceSymbols/main.ts#L44-L52

if (Array.isArray(this.workspace.workspaceFolders)) {
    this.workspace.workspaceFolders.forEach(workspaceFolder => {
        const pythonSettings = this.configurationService.getSettings(workspaceFolder ? workspaceFolder.uri : undefined);
        if (pythonSettings.workspaceSymbols.rebuildOnStart) {
            const promises = this.buildWorkspaceSymbols(true);
            return Promise.all(promises);
        }
    });
}

For python.workspaceSymbols.rebuildOnFileSave, add these lines in the constructor

this.documents = serviceContainer.get<IDocumentManager>(IDocumentManager);
this.disposables.push(this.documents.onDidSaveTextDocument(e => this.onDocumentSaved(e)));

and create the method

private onDocumentSaved(e: TextDocument) {
    const workspaceFolder = this.workspace.getWorkspaceFolder(e.uri);
    const pythonSettings = this.configurationService.getSettings(workspaceFolder ? workspaceFolder.uri : undefined);
    if (pythonSettings.workspaceSymbols.rebuildOnFileSave) {
        const promises = this.buildWorkspaceSymbols(true);
        return Promise.all(promises);
    }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

coc-python - npm
Install ctags for Workspace Symbols, from here, or using brew install ctags on macOS. Useful commands. Open the Command List (use :CocCommand ...
Read more >
Better Python Object Serialization - Planet Python
The Fellow Work Group is looking for more members from all around the world! ... rebuildOnStart” to true, or rebuilt on every file...
Read more >
Harami | PDF | Html Element | Bracket - Scribd
Controls auto save of dirty files. Accepted values: 'off', 'afterDelay',. 'onFocusChange' (editor loses focus), 'onWindowChange' (window loses focus).
Read more >
VScode设置界面怎么改回UI - CSDN
Only works before elements, not inside tags or for text. ... qualified path to the ctags executable (else leave as ctags, assuming it...
Read more >
After upgrading to 1.30.2, formatting disorder #1062 - Issuehunt
limitSymbolsToIncludedHeaders" is either not specified or set to "${default}". ... add a directory change command to allow relative path loading to work.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found