Skip to content

Commit d3e36a3

Browse files
authored
fix: completion value with dash (#832)
1 parent 832202f commit d3e36a3

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

src/languageservice/services/yamlCompletion.ts

-3
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,6 @@ export class YamlCompletion {
168168
overwriteRange = Range.create(nodeStartPos, nodeEndPos);
169169
} else if (node && isScalar(node) && node.value) {
170170
const start = document.positionAt(node.range[0]);
171-
if (offset > 0 && start.character > 0 && text.charAt(offset - 1) === '-') {
172-
start.character -= 1;
173-
}
174171
overwriteRange = Range.create(start, document.positionAt(node.range[1]));
175172
} else if (node && isScalar(node) && node.value === null && currentWord === '-') {
176173
overwriteRange = Range.create(position, position);

test/autoCompletion.test.ts

+25
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,31 @@ describe('Auto Completion Tests', () => {
228228
.then(done, done);
229229
});
230230

231+
it('Autocomplete on default value (with value content contains dash)', (done) => {
232+
languageService.addSchema(SCHEMA_ID, {
233+
type: 'object',
234+
properties: {
235+
name: {
236+
type: 'string',
237+
default: 'yaml-language',
238+
},
239+
},
240+
});
241+
const content = 'name: yaml-';
242+
const completion = parseSetup(content, content.length);
243+
completion
244+
.then(function (result) {
245+
assert.equal(result.items.length, 1);
246+
assert.deepEqual(
247+
result.items[0],
248+
createExpectedCompletion('yaml-language', 'yaml-language', 0, 6, 0, 11, 12, 2, {
249+
detail: 'Default value',
250+
})
251+
);
252+
})
253+
.then(done, done);
254+
});
255+
231256
it('Autocomplete on boolean value (without value content)', (done) => {
232257
languageService.addSchema(SCHEMA_ID, {
233258
type: 'object',

0 commit comments

Comments
 (0)