Skip to content

Conversation

Shane-XB-Qian
Copy link
Contributor

closes #516

@@ -63,8 +63,10 @@ export default class Linter {
folders: LSP.WorkspaceFolder[],
): Promise<ShellcheckResult> {
const args = ['--format=json1', '--external-sources', `--source-path=${this.cwd}`]
for (const folder of folders) {
args.push(`--source-path=${folder.name}`)
if (Array.isArray(folders)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In which case is folders not an array? What is it?

I'm asking as the type signature here explicitly says that it should always be an array of LSP.WorkspaceFolder

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

according to rough looking to lsp specification,
looks it said It can be 'null' if the client supports workspace folders but none are configured.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the problem looks was the previous statement before L92.

@Shane-XB-Qian
Copy link
Contributor Author

      const folders = this.clientCapabilities.workspace?.workspaceFolders
        ? await connection.workspace.getWorkspaceFolders()
        : []
      const lintDiagnostics = await this.linter.lint(change.document, folders || [])
  1. this.clientCapabilities.workspace?.workspaceFolders this got from initialize and that is true.
  2. however await connection.workspace.getWorkspaceFolders() looks send workspace/workspaceFolders to lsp client, but got {'id': 0, 'jsonrpc': '2.0', 'result': {}}
  3. so that folders looks was a {} ?! <--------- !!!

so the problem is:

  1. could it get from this.clientCapabilities.workspaceFolders when/if this.clientCapabilities.workspace?.workspaceFolders is true?
  2. should lsp client response with result: ........ something else or could be {}?
  3. anyway, {} perhaps that's the direct problem.

@Shane-XB-Qian
Copy link
Contributor Author

Shane-XB-Qian commented Nov 17, 2022

and looks others lsp server, i saw they just get workspaces folders from clientCapabilities.workspaceFolders, did not send/get from lsp workspace/workspaceFolders method.

@Shane-XB-Qian
Copy link
Contributor Author

@skovhus that should be a bug (or un-impl feature) of lsp client, i've opened a pr to correct/impl that.
// see yegappan/lsp#114

// but this pr to bash lsp server, perhaps should be better merged too, since varied lsp client may send others type of folders var.

@skovhus
Copy link
Collaborator

skovhus commented Nov 25, 2022

but this pr to bash lsp server, perhaps should be better merged too, since varied lsp client may send others type of folders var.

We shouldn't extend the LSP server here to support faulty clients – we want to follow the LSP standard. But thanks for fixing yegappan/lsp#114

I'm closing this for now, but thanks for looking into it.

@skovhus skovhus closed this Nov 25, 2022
@Shane-XB-Qian Shane-XB-Qian deleted the pr_folders_arrary branch November 25, 2022 11:04
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.

TypeError: folders is not iterable
2 participants