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

show detail when document is not available #652

Merged
merged 2 commits into from
Jun 13, 2023

Conversation

braineo
Copy link
Contributor

@braineo braineo commented Jun 13, 2023

Mimic vscode behavior

@manateelazycat
Copy link
Owner

Can you add some test code for this PR?

@braineo
Copy link
Contributor Author

braineo commented Jun 13, 2023

Can you add some test code for this PR?

this is a particular case when auto import is enabled in tsserver. i take a look at the setup, but it requires a project with proper tsconfig and typescript language server config, which does not seem easy

the language server config

{
  "name": "typescript",
  "languageId": "TypeScript",
  "command": [
    "typescript-language-server",
    "--stdio"
  ],
  "initializationOptions": {
    "preferences": {
      "importModuleSpecifierPreference": "relative",
      "includePackageJsonAutoImports": "on",
      "includeCompletionsForModuleExports": true,
      "includeExternalModuleExports": true,
      "includeInsertTextCompletions": true
    }
  }
}

the response from tsserver

{
   "jsonrpc": "2.0",
   "id": 30665,
   "result": {
      "label": "utilities",
      "kind": 6,
      "sortText": "\uffff16",
      "data": {
         "file": "/home/user/todo-manager/src/views/inspection/index.tsx",
         "line": 71,
         "offset": 13,
         "entryNames": [
            {
               "name": "utilities",
               "source": "@org/share",
               "data": {
                  "exportName": "utilities",
                  "moduleSpecifier": "@org/share",
                  "fileName": "/home/user/todo-manager/node_modules/@org/share/build/index.d.ts"
               }
            }
         ]
      },
      "detail": "Auto import from '@org/share'\nimport utilities",
      "additionalTextEdits": [
         {
            "range": {
               "start": {
                  "line": 2,
                  "character": 0
               },
               "end": {
                  "line": 2,
                  "character": 0
               }
            },
            "newText": "import { utilities } from '@org/share';\n"
         }
      ]
   }
}

@braineo braineo marked this pull request as ready for review June 13, 2023 10:52
@manateelazycat manateelazycat merged commit 8b4cd92 into manateelazycat:master Jun 13, 2023
2 checks passed
@manateelazycat
Copy link
Owner

Thanks, patch looks good.

@braineo braineo deleted the show-detail-when-no-doc branch June 13, 2023 13:32
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.

None yet

2 participants