Visual Studio 2013 JavaScript/TypeScript奇数缩进行为
在处理我的TypeScript代码时,代码的自动缩进存在问题。我将VS2013与Resharper一起使用 问题主要发生在方法链接上 例如,使用承诺:Visual Studio 2013 JavaScript/TypeScript奇数缩进行为,javascript,visual-studio,visual-studio-2013,resharper,typescript,Javascript,Visual Studio,Visual Studio 2013,Resharper,Typescript,在处理我的TypeScript代码时,代码的自动缩进存在问题。我将VS2013与Resharper一起使用 问题主要发生在方法链接上 例如,使用承诺: someService.GetSomeProperties().then(x => { return otherService.doSomethingWithX(x.map(y => y.id)); }).then(x => { // Pressing enter sets the cursor to this
someService.GetSomeProperties().then(x => {
return otherService.doSomethingWithX(x.map(y => y.id));
}).then(x => {
// Pressing enter sets the cursor to this position
// Using document format (CTRL+K,CTRL+D) the code moves to this level
return '';
}).then(x => { // Pressing enter from here
// Moves the previous line to it's position and cursor here
return 'a';
}).then(x => {
// However document format moves this code block to this indention level
// as well
}).then(x => {
// Follow up chaining remains the same
});
从“症状”来看,这种行为似乎来自于一般的多行语句
我已经查看了VS2013的选项和R#s,但我找不到任何对这种行为有任何影响的选项
有人知道怎么修吗
有人知道怎么修吗
如果将放在新行中(即每个顶级函数都有自己的行)并始终使用分号,则此问题是固定的:
someService.GetSomeProperties()
.then(x => {
return otherService.doSomethingWithX(x.map(y => y.id));
})
.then(x => {
// Pressing enter sets the cursor to this position
// Using document format (CTRL+K,CTRL+D) the code moves to this level
return '';
})
.then(x => { // Pressing enter from here
// Moves the previous line to it's position and cursor here
return 'a';
})
.then(x => {
// However document format moves this code block to this indention level
// as well
})
.then(x => {
// Follow up chaining remains the same
});
我建议。这是怎么回答我的问题的?谁推荐这种款式?AFAIK风格是一个偏好的问题,我同意分号(我想知道你在哪里看到任何缺少的分号),但是新行上的then
与人们争论是否应该将else语句写成}else{
或换行}
\nelse是一样的{
。分号不仅仅是样式,它们可以影响行为,如果它们仅仅用于美学目的,我不在乎别人使用哪一个,只要它们是一致的。例如,在Lua中,它们纯粹是样式问题,并且总是可以用空格代替(当然字符串文字除外).。那么
在另一方面,无论你把它放在同一行还是下一行,它都不受影响,所以这只是风格。我同意@Aidiakapi。分号被广泛认为是“必须的”即使在理论上大部分是可选的。将然后
放在新行上当然是一个风格问题,但如果切换IDE不是一个选项,我更喜欢这种格式,而不是断断续续的格式,至少它是一致的,有意义的(不像断断续续的缩进)。