mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 04:43:37 -05:00
add getOption
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user