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

Fix object property completion when have hyphen #1808

Merged
merged 3 commits into from
Jul 31, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions server/src/modes/script/javascript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import {
MarkupContent,
CodeAction,
CodeActionKind,
WorkspaceEdit
WorkspaceEdit,
InsertTextFormat
} from 'vscode-languageserver-types';
import { LanguageMode } from '../../embeddedSupport/languageModes';
import { VueDocumentRegions, LanguageRange } from '../../embeddedSupport/embeddedSupport';
Expand Down Expand Up @@ -157,17 +158,29 @@ export async function getJavascriptMode(
const entries = completions.entries.filter(entry => entry.name !== '__vueEditorBridge');
return {
isIncomplete: false,
items: entries.map((entry, index) => {
items: entries.map(entry => {
const range = entry.replacementSpan && convertRange(scriptDoc, entry.replacementSpan);
const filterText = entry.insertText && range && entry.insertText[0] === '[' ? '.' + entry.name : undefined;
const { label, detail } = calculateLabelAndDetailTextForPathImport(entry);
const kind = toCompletionItemKind(entry.kind);
const insertTextFormat =
kind === CompletionItemKind.Function || kind === CompletionItemKind.Method
Copy link
Member

Choose a reason for hiding this comment

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

In VS Code this is behind typescript.suggest.completeFunctionCalls which defaults to false. I don't think we should turn this on by default.

? InsertTextFormat.Snippet
: undefined;
const insertText = entry.insertText || entry.name;
Copy link
Member

Choose a reason for hiding this comment

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

No need to do this. If entry.insertText is undefined just pass it in.


return {
uri: doc.uri,
position,
preselect: entry.isRecommended ? true : undefined,
Copy link
Member

Choose a reason for hiding this comment

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

I'll split this into another commit...Let one PR do one thing, don't include unrelated changes, or it becomes harder to review. Thanks!

label,
detail,
sortText: entry.sortText + index,
filterText,
insertTextFormat,
sortText: entry.sortText,
kind: toCompletionItemKind(entry.kind),
textEdit: range && TextEdit.replace(range, entry.name),
textEdit: range && TextEdit.replace(range, insertText),
insertText: range ? undefined : insertText,
data: {
// data used for resolving item details (see 'doResolve')
languageId: scriptDoc.languageId,
Expand Down