Skip to content

Commit 159d215

Browse files
Fix "convert tabs to space" quickfix for "indentation cannot be tabs" (#1057)
I think the error message changed when switching validators. There is nothing more concrete (such as a diagnostic code) to identify the "identation cannot be tabs" diagnostics. Fixes #1052 Signed-off-by: David Thompson <davthomp@redhat.com> Co-authored-by: Muthurajan Sivasubramanian <93245779+msivasubramaniaan@users.noreply.github.com>
1 parent 4a5c6ca commit 159d215

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/languageservice/services/yamlCodeActions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export class YamlCodeActions {
9797
const textBuff = new TextBuffer(document);
9898
const processedLine: number[] = [];
9999
for (const diag of diagnostics) {
100-
if (diag.message === 'Using tabs can lead to unpredictable results') {
100+
if (diag.message === 'Tabs are not allowed as indentation') {
101101
if (processedLine.includes(diag.range.start.line)) {
102102
continue;
103103
}

test/yamlCodeActions.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ describe('CodeActions Tests', () => {
107107
describe('Convert TAB to Spaces', () => {
108108
it('should add "Convert TAB to Spaces" CodeAction', () => {
109109
const doc = setupTextDocument('foo:\n\t- bar');
110-
const diagnostics = [createExpectedError('Using tabs can lead to unpredictable results', 1, 0, 1, 1, 1, JSON_SCHEMA_LOCAL)];
110+
const diagnostics = [createExpectedError('Tabs are not allowed as indentation', 1, 0, 1, 1, 1, JSON_SCHEMA_LOCAL)];
111111
const params: CodeActionParams = {
112112
context: CodeActionContext.create(diagnostics),
113113
range: undefined,
@@ -123,7 +123,7 @@ describe('CodeActions Tests', () => {
123123

124124
it('should support current indentation chars settings', () => {
125125
const doc = setupTextDocument('foo:\n\t- bar');
126-
const diagnostics = [createExpectedError('Using tabs can lead to unpredictable results', 1, 0, 1, 1, 1, JSON_SCHEMA_LOCAL)];
126+
const diagnostics = [createExpectedError('Tabs are not allowed as indentation', 1, 0, 1, 1, 1, JSON_SCHEMA_LOCAL)];
127127
const params: CodeActionParams = {
128128
context: CodeActionContext.create(diagnostics),
129129
range: undefined,
@@ -139,7 +139,7 @@ describe('CodeActions Tests', () => {
139139

140140
it('should provide "Convert all Tabs to Spaces"', () => {
141141
const doc = setupTextDocument('foo:\n\t\t\t- bar\n\t\t');
142-
const diagnostics = [createExpectedError('Using tabs can lead to unpredictable results', 1, 0, 1, 3, 1, JSON_SCHEMA_LOCAL)];
142+
const diagnostics = [createExpectedError('Tabs are not allowed as indentation', 1, 0, 1, 3, 1, JSON_SCHEMA_LOCAL)];
143143
const params: CodeActionParams = {
144144
context: CodeActionContext.create(diagnostics),
145145
range: undefined,
@@ -188,8 +188,8 @@ describe('CodeActions Tests', () => {
188188

189189
describe('Convert to Block Style', () => {
190190
it(' should generate action to convert flow map to block map ', () => {
191-
const yaml = `host: phl-42
192-
datacenter: {location: canada , cab: 15}
191+
const yaml = `host: phl-42
192+
datacenter: {location: canada , cab: 15}
193193
animals: [dog , cat , mouse] `;
194194
const doc = setupTextDocument(yaml);
195195
const diagnostics = [

0 commit comments

Comments
 (0)