Skip to content

Indenting of inserted completion items is incorrect #44200

@DanTup

Description

@DanTup

I have this code (it's Dart, the indenting is 2 spaces and the editor has this set correct). autoIndent is off.

danny(int iiii) {
  if (true) {
    inser^
  }
}

The ^ represents the cursor. I have a completion provider implemented like this:

public provideCompletionItems(
	document: TextDocument, position: Position, token: CancellationToken, context: CompletionContext,
): CompletionList {
	const comp = new CompletionItem("INSERT ME");
	comp.insertText = "@override\n    method() {\n      // TODO: implement method\n      return 
super.method();\n    }";super.method();\n  }";
	comp.label = "INSERT ME";
	return new CompletionList([comp]);
}

When I commit that completion item at the cursor location, I end up with this:

danny(int iiii) {
  if (true) {
    @override
        method() {
          // TODO: implement method
          return super.method();
        }
  }
}

The line starting with method is intented by 8 spaces, but it was only was 4 in my completion item. I presume Code is assuming that the completion is based on not being indented and it's being helpful; but in my case the indentation from my language server is accurate.

Is there a way to tell Code not to try and re-indent things?

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugeditor-autoindentEditor auto indentation issues

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions