Skip to content

Commit

Permalink
Fix object property completion when have hyphen
Browse files Browse the repository at this point in the history
  • Loading branch information
yoyo930021 committed Mar 26, 2020
1 parent dcf66c4 commit 02208d8
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions server/src/modes/script/javascript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import {
Position,
FormattingOptions,
DiagnosticTag,
MarkupContent
MarkupContent,
InsertTextFormat
} from 'vscode-languageserver-types';
import { LanguageMode } from '../../embeddedSupport/languageModes';
import { VueDocumentRegions, LanguageRange } from '../../embeddedSupport/embeddedSupport';
Expand Down Expand Up @@ -154,17 +155,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
? InsertTextFormat.Snippet
: undefined;
const insertText = entry.insertText || entry.name;

return {
uri: doc.uri,
position,
preselect: entry.isRecommended ? true : undefined,
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

0 comments on commit 02208d8

Please sign in to comment.