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 {
|
||||
open:string;
|
||||
|
|
|
@ -9,6 +9,7 @@ import {parse} from 'vs/base/common/json';
|
|||
import {readFile} from 'vs/base/node/pfs';
|
||||
import {IRichEditConfiguration} from 'vs/editor/common/modes/supports/richEditSupport';
|
||||
import {IModeService} from 'vs/editor/common/services/modeService';
|
||||
import {IAutoClosingPair} from 'vs/editor/common/modes';
|
||||
|
||||
type CharacterPair = [string, string];
|
||||
|
||||
|
@ -20,6 +21,8 @@ interface ICommentRule {
|
|||
interface ILanguageConfiguration {
|
||||
comments?: ICommentRule;
|
||||
brackets?: CharacterPair[];
|
||||
autoClosingPairs?: CharacterPair[];
|
||||
surroundingPairs?: CharacterPair[];
|
||||
}
|
||||
|
||||
export class LanguageConfigurationFileHandler {
|
||||
|
@ -75,15 +78,29 @@ export class LanguageConfigurationFileHandler {
|
|||
|
||||
if (configuration.brackets) {
|
||||
richEditConfig.brackets = configuration.brackets;
|
||||
}
|
||||
|
||||
if (configuration.autoClosingPairs) {
|
||||
richEditConfig.__characterPairSupport = {
|
||||
autoClosingPairs: configuration.brackets.map(pair => {
|
||||
let [open, close] = pair;
|
||||
return { open: open, close: close };
|
||||
})
|
||||
autoClosingPairs: this._mapCharacterPairs(configuration.autoClosingPairs)
|
||||
};
|
||||
} 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);
|
||||
}
|
||||
|
||||
private _mapCharacterPairs(pairs:CharacterPair[]): IAutoClosingPair[] {
|
||||
return pairs.map(pair => {
|
||||
let [open, close] = pair;
|
||||
return { open: open, close: close };
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue