add getOption
This commit is contained in:
parent
f65c865957
commit
273a0dbdfe
3 changed files with 13 additions and 6 deletions
|
@ -3530,6 +3530,10 @@ namespace FourSlashInterface {
|
|||
public setOption(name: string, value: any): void {
|
||||
(<any>this.state.formatCodeSettings)[name] = value;
|
||||
}
|
||||
|
||||
public getOption(name: keyof ts.FormatCodeSettings) {
|
||||
return this.state.formatCodeSettings[name];
|
||||
}
|
||||
}
|
||||
|
||||
export class Cancellation {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
////}
|
||||
/////*PlaceOpenBraceOnNewLineForControlBlocks*/if (true) {
|
||||
////}
|
||||
/////*InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces*/{ var t = 1}; var {a,b } = { a: 'sw', b:'r' };
|
||||
/////*InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces*/{ var t = 1}; var {a,b } = { a: 'sw', b:'r' };function f( { a, b}) { }
|
||||
|
||||
runTest("InsertSpaceAfterCommaDelimiter", "[1, 2, 3];[72,];", "[1,2,3];[72,];");
|
||||
runTest("InsertSpaceAfterSemicolonInForStatements", "for (i = 0; i; i++);", "for (i = 0;i;i++);");
|
||||
|
@ -26,9 +26,9 @@ runTest("InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces", "`${ 1 }`
|
|||
runTest("InsertSpaceAfterTypeAssertion", "const bar = <Bar> Thing.getFoo();", "const bar = <Bar>Thing.getFoo();");
|
||||
runTest("PlaceOpenBraceOnNewLineForFunctions", "class foo", "class foo {");
|
||||
runTest("PlaceOpenBraceOnNewLineForControlBlocks", "if ( true )", "if ( true ) {");
|
||||
runTest("InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces", "{ var t = 1 }; var { a, b } = { a: 'sw', b: 'r' };", "{var t = 1}; var {a, b} = {a: 'sw', b: 'r'};");
|
||||
|
||||
runTest("InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces", "{ var t = 1 }; var { a, b } = { a: 'sw', b: 'r' }; function f({ a, b }) { }", "{var t = 1}; var {a, b} = {a: 'sw', b: 'r'}; function f({a, b}) {}");
|
||||
|
||||
const defaultFormatOption = format.copyFormatOptions();
|
||||
function runTest(propertyName: string, expectedStringWhenTrue: string, expectedStringWhenFalse: string) {
|
||||
// Go to the correct file
|
||||
goTo.marker(propertyName);
|
||||
|
@ -52,4 +52,6 @@ function runTest(propertyName: string, expectedStringWhenTrue: string, expectedS
|
|||
// Verify
|
||||
goTo.marker(propertyName);
|
||||
verify.currentLineContentIs(expectedStringWhenTrue);
|
||||
|
||||
format.setOption(propertyName, defaultFormatOption[propertyName])
|
||||
}
|
|
@ -294,9 +294,10 @@ declare namespace FourSlashInterface {
|
|||
setFormatOptions(options: FormatCodeOptions): any;
|
||||
selection(startMarker: string, endMarker: string): void;
|
||||
onType(posMarker: string, key: string): void;
|
||||
setOption(name: string, value: number): any;
|
||||
setOption(name: string, value: string): any;
|
||||
setOption(name: string, value: boolean): any;
|
||||
setOption(name: string, value: number): void;
|
||||
setOption(name: string, value: string): void;
|
||||
setOption(name: string, value: boolean): void;
|
||||
getOption(name: string): number|string|boolean;
|
||||
}
|
||||
class cancellation {
|
||||
resetCancelled(): void;
|
||||
|
|
Loading…
Reference in a new issue