feat: property snippets#36
Conversation
…-yaml-language-server into fix/suggest-hyphen-in-arrays
…y' into feat/property-snippets
| return `${resultText}\n${indent}- ${ | ||
| this.getInsertTextForArray(propertySchema.items, separatorAfter, 1, indent).insertText | ||
| }`; | ||
| let insertText = this.getInsertTextForArray(propertySchema.items, separatorAfter, collector, 1, indent).insertText; |
There was a problem hiding this comment.
fix a few existing issues with snippet indentation
| insertIndex = 1 | ||
| ): InsertText { | ||
| let insertText = ''; | ||
| if (Array.isArray(schema.defaultSnippets) && schema.defaultSnippets.length === 1) { |
There was a problem hiding this comment.
the main change of this PR is to add snippets to the object
| } | ||
| arrayTemplate = arrayInsertLines.join('\n'); | ||
| } | ||
| const arrayInsertResult = this.getInsertTextForArray( |
There was a problem hiding this comment.
refactor and fix indentation
use new addIndentationToMultilineString function
| continue; | ||
| } | ||
|
|
||
| if ((arrayDepth === 0 && type === 'array') || isArray) { |
There was a problem hiding this comment.
refactor, uses a new collector.context concept to distinguish between different scenarios
It wasn't possible to detect if a hyphen was missing or if the cursor was after the colon
| for (let i = 0; i < obj.length; i++) { | ||
| let pseudoObj = obj[i]; | ||
| if (typeof obj[i] !== 'object') { | ||
| if (typeof obj[i] !== 'object' || obj[i] === null) { |
There was a problem hiding this comment.
fix the null issue when the snippet contains null as a value
| return offset; | ||
| } | ||
|
|
||
| export function addIndentationToMultilineString(text: string, firstIndent: string, nextIndent: string): string { |
There was a problem hiding this comment.
Unified function to indent multiline strings, this logic was written multiple times before
… yaml - because it's properties from the parent object
|
PR to original repo was created, so it's possible to cancel this |
What does this PR do?
the main purpose of this PR is to support property snippets


intellisense
will insert the value from the snippet
but this PR also unifies related changes from PRs:
redhat-developer#755
redhat-developer#901
and include some other snippet fixes
What issues does this PR fix or reference?
no ref
Is it tested? How?
existing and a few new unit tests
tested by QA in our separate branch