mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
Add CoffeeScript quote surroundingPairs
Updating language configuration to support autoClosingPairs and surroundingPairs settings. Related to #3418
This commit is contained in:
parent
36a964b59d
commit
c5744ae430
|
@ -7,5 +7,19 @@
|
||||||
["{", "}"],
|
["{", "}"],
|
||||||
["[", "]"],
|
["[", "]"],
|
||||||
["(", ")"]
|
["(", ")"]
|
||||||
|
],
|
||||||
|
"autoClosingPairs": [
|
||||||
|
["{", "}"],
|
||||||
|
["[", "]"],
|
||||||
|
["(", ")"],
|
||||||
|
["\"", "\""],
|
||||||
|
["'", "'"]
|
||||||
|
],
|
||||||
|
"surroundingPairs": [
|
||||||
|
["{", "}"],
|
||||||
|
["[", "]"],
|
||||||
|
["(", ")"],
|
||||||
|
["\"", "\""],
|
||||||
|
["'", "'"]
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -705,7 +705,7 @@ export interface ICommentsConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface used to support insertion of matching characters like brackets and qoutes.
|
* Interface used to support insertion of matching characters like brackets and quotes.
|
||||||
*/
|
*/
|
||||||
export interface IAutoClosingPair {
|
export interface IAutoClosingPair {
|
||||||
open:string;
|
open:string;
|
||||||
|
|
|
@ -9,6 +9,7 @@ import {parse} from 'vs/base/common/json';
|
||||||
import {readFile} from 'vs/base/node/pfs';
|
import {readFile} from 'vs/base/node/pfs';
|
||||||
import {IRichEditConfiguration} from 'vs/editor/common/modes/supports/richEditSupport';
|
import {IRichEditConfiguration} from 'vs/editor/common/modes/supports/richEditSupport';
|
||||||
import {IModeService} from 'vs/editor/common/services/modeService';
|
import {IModeService} from 'vs/editor/common/services/modeService';
|
||||||
|
import {IAutoClosingPair} from 'vs/editor/common/modes';
|
||||||
|
|
||||||
type CharacterPair = [string, string];
|
type CharacterPair = [string, string];
|
||||||
|
|
||||||
|
@ -20,6 +21,8 @@ interface ICommentRule {
|
||||||
interface ILanguageConfiguration {
|
interface ILanguageConfiguration {
|
||||||
comments?: ICommentRule;
|
comments?: ICommentRule;
|
||||||
brackets?: CharacterPair[];
|
brackets?: CharacterPair[];
|
||||||
|
autoClosingPairs?: CharacterPair[];
|
||||||
|
surroundingPairs?: CharacterPair[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class LanguageConfigurationFileHandler {
|
export class LanguageConfigurationFileHandler {
|
||||||
|
@ -75,15 +78,29 @@ export class LanguageConfigurationFileHandler {
|
||||||
|
|
||||||
if (configuration.brackets) {
|
if (configuration.brackets) {
|
||||||
richEditConfig.brackets = configuration.brackets;
|
richEditConfig.brackets = configuration.brackets;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configuration.autoClosingPairs) {
|
||||||
richEditConfig.__characterPairSupport = {
|
richEditConfig.__characterPairSupport = {
|
||||||
autoClosingPairs: configuration.brackets.map(pair => {
|
autoClosingPairs: this._mapCharacterPairs(configuration.autoClosingPairs)
|
||||||
let [open, close] = pair;
|
|
||||||
return { open: open, close: close };
|
|
||||||
})
|
|
||||||
};
|
};
|
||||||
|
} else if (configuration.brackets) {
|
||||||
|
richEditConfig.__characterPairSupport = {
|
||||||
|
autoClosingPairs: this._mapCharacterPairs(configuration.brackets)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (richEditConfig.__characterPairSupport && configuration.surroundingPairs) {
|
||||||
|
richEditConfig.__characterPairSupport.surroundingPairs = this._mapCharacterPairs(configuration.surroundingPairs);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._modeService.registerRichEditSupport(modeId, richEditConfig);
|
this._modeService.registerRichEditSupport(modeId, richEditConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _mapCharacterPairs(pairs:CharacterPair[]): IAutoClosingPair[] {
|
||||||
|
return pairs.map(pair => {
|
||||||
|
let [open, close] = pair;
|
||||||
|
return { open: open, close: close };
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue