本文整理匯總了TypeScript中vs/editor/common/controller/cursorCommon.isQuote函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript isQuote函數的具體用法?TypeScript isQuote怎麽用?TypeScript isQuote使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了isQuote函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: _isAutoClosingCloseCharType
private static _isAutoClosingCloseCharType(config: CursorConfiguration, model: ITextModel, selections: Selection[], ch: string): boolean {
const autoCloseConfig = isQuote(ch) ? config.autoClosingQuotes : config.autoClosingBrackets;
if (autoCloseConfig === 'never' || !config.autoClosingPairsClose.hasOwnProperty(ch)) {
return false;
}
const isEqualPair = (ch === config.autoClosingPairsClose[ch]);
for (let i = 0, len = selections.length; i < len; i++) {
const selection = selections[i];
if (!selection.isEmpty()) {
return false;
}
const position = selection.getPosition();
const lineText = model.getLineContent(position.lineNumber);
const afterCharacter = lineText.charAt(position.column - 1);
if (afterCharacter !== ch) {
return false;
}
if (isEqualPair) {
const lineTextBeforeCursor = lineText.substr(0, position.column - 1);
const chCntBefore = this._countNeedlesInHaystack(lineTextBeforeCursor, ch);
if (chCntBefore % 2 === 0) {
return false;
}
}
}
return true;
}
示例2: _shouldSurroundChar
private static _shouldSurroundChar(config: CursorConfiguration, ch: string): boolean {
if (isQuote(ch)) {
return (config.autoSurround === 'quotes' || config.autoSurround === 'languageDefined');
} else {
// Character is a bracket
return (config.autoSurround === 'brackets' || config.autoSurround === 'languageDefined');
}
}
示例3: _isSurroundSelectionType
private static _isSurroundSelectionType(config: CursorConfiguration, model: ITextModel, selections: Selection[], ch: string): boolean {
if (!TypeOperations._shouldSurroundChar(config, ch) || !config.surroundingPairs.hasOwnProperty(ch)) {
return false;
}
const isTypingAQuoteCharacter = isQuote(ch);
for (let i = 0, len = selections.length; i < len; i++) {
const selection = selections[i];
if (selection.isEmpty()) {
return false;
}
let selectionContainsOnlyWhitespace = true;
for (let lineNumber = selection.startLineNumber; lineNumber <= selection.endLineNumber; lineNumber++) {
const lineText = model.getLineContent(lineNumber);
const startIndex = (lineNumber === selection.startLineNumber ? selection.startColumn - 1 : 0);
const endIndex = (lineNumber === selection.endLineNumber ? selection.endColumn - 1 : lineText.length);
const selectedText = lineText.substring(startIndex, endIndex);
if (/[^ \t]/.test(selectedText)) {
// this selected text contains something other than whitespace
selectionContainsOnlyWhitespace = false;
break;
}
}
if (selectionContainsOnlyWhitespace) {
return false;
}
if (isTypingAQuoteCharacter && selection.startLineNumber === selection.endLineNumber && selection.startColumn + 1 === selection.endColumn) {
const selectionText = model.getValueInRange(selection);
if (isQuote(selectionText)) {
// Typing a quote character on top of another quote character
// => disable surround selection type
return false;
}
}
}
return true;
}
示例4: _isAutoClosingPairDelete
private static _isAutoClosingPairDelete(config: CursorConfiguration, model: ICursorSimpleModel, selections: Selection[]): boolean {
if (config.autoClosingBrackets === 'never' && config.autoClosingQuotes === 'never') {
return false;
}
for (let i = 0, len = selections.length; i < len; i++) {
const selection = selections[i];
const position = selection.getPosition();
if (!selection.isEmpty()) {
return false;
}
const lineText = model.getLineContent(position.lineNumber);
const character = lineText[position.column - 2];
if (!config.autoClosingPairsOpen.hasOwnProperty(character)) {
return false;
}
if (isQuote(character)) {
if (config.autoClosingQuotes === 'never') {
return false;
}
} else {
if (config.autoClosingBrackets === 'never') {
return false;
}
}
const afterCharacter = lineText[position.column - 1];
const closeCharacter = config.autoClosingPairsOpen[character];
if (afterCharacter !== closeCharacter) {
return false;
}
}
return true;
}
示例5: compositionEndWithInterceptors
public static compositionEndWithInterceptors(prevEditOperationType: EditOperationType, config: CursorConfiguration, model: ITextModel, selections: Selection[]): EditOperationResult {
if (config.autoClosingQuotes === 'never') {
return null;
}
let commands: ICommand[] = [];
for (let i = 0; i < selections.length; i++) {
if (!selections[i].isEmpty()) {
continue;
}
const position = selections[i].getPosition();
const lineText = model.getLineContent(position.lineNumber);
const ch = lineText.charAt(position.column - 2);
if (config.autoClosingPairsClose.hasOwnProperty(ch)) { // first of all, it's a closing tag
if (ch === config.autoClosingPairsClose[ch] /** isEqualPair */) {
const lineTextBeforeCursor = lineText.substr(0, position.column - 2);
const chCntBefore = this._countNeedlesInHaystack(lineTextBeforeCursor, ch);
if (chCntBefore % 2 === 1) {
continue; // it pairs with the opening tag.
}
}
}
// As we are not typing in a new character, so we don't need to run `_runAutoClosingCloseCharType`
// Next step, let's try to check if it's an open char.
if (config.autoClosingPairsOpen.hasOwnProperty(ch)) {
if (isQuote(ch) && position.column > 2) {
const wordSeparators = getMapForWordSeparators(config.wordSeparators);
const characterBeforeCode = lineText.charCodeAt(position.column - 3);
const characterBeforeType = wordSeparators.get(characterBeforeCode);
if (characterBeforeType === WordCharacterClass.Regular) {
continue;
}
}
const characterAfter = lineText.charAt(position.column - 1);
if (characterAfter) {
let isBeforeCloseBrace = TypeOperations._isBeforeClosingBrace(config, ch, characterAfter);
let shouldAutoCloseBefore = isQuote(ch) ? config.shouldAutoCloseBefore.quote : config.shouldAutoCloseBefore.bracket;
if (isBeforeCloseBrace) {
// In normal auto closing logic, we will auto close if the cursor is even before a closing brace intentionally.
// However for composition mode, we do nothing here as users might clear all the characters for composition and we don't want to do a unnecessary auto close.
// Related: microsoft/vscode#57250.
continue;
}
if (!shouldAutoCloseBefore(characterAfter)) {
continue;
}
}
if (!model.isCheapToTokenize(position.lineNumber)) {
// Do not force tokenization
continue;
}
model.forceTokenization(position.lineNumber);
const lineTokens = model.getLineTokens(position.lineNumber);
let shouldAutoClosePair = false;
try {
shouldAutoClosePair = LanguageConfigurationRegistry.shouldAutoClosePair(ch, lineTokens, position.column - 1);
} catch (e) {
onUnexpectedError(e);
}
if (shouldAutoClosePair) {
const closeCharacter = config.autoClosingPairsOpen[ch];
commands[i] = new ReplaceCommandWithOffsetCursorState(selections[i], closeCharacter, 0, -closeCharacter.length);
}
}
}
return new EditOperationResult(EditOperationType.Typing, commands, {
shouldPushStackElementBefore: true,
shouldPushStackElementAfter: false
});
}
示例6: _isAutoClosingOpenCharType
private static _isAutoClosingOpenCharType(config: CursorConfiguration, model: ITextModel, selections: Selection[], ch: string): boolean {
const chIsQuote = isQuote(ch);
const autoCloseConfig = chIsQuote ? config.autoClosingQuotes : config.autoClosingBrackets;
if (autoCloseConfig === 'never' || !config.autoClosingPairsOpen.hasOwnProperty(ch)) {
return false;
}
let shouldAutoCloseBefore = chIsQuote ? config.shouldAutoCloseBefore.quote : config.shouldAutoCloseBefore.bracket;
for (let i = 0, len = selections.length; i < len; i++) {
const selection = selections[i];
if (!selection.isEmpty()) {
return false;
}
const position = selection.getPosition();
const lineText = model.getLineContent(position.lineNumber);
// Do not auto-close ' or " after a word character
if (chIsQuote && position.column > 1) {
const wordSeparators = getMapForWordSeparators(config.wordSeparators);
const characterBeforeCode = lineText.charCodeAt(position.column - 2);
const characterBeforeType = wordSeparators.get(characterBeforeCode);
if (characterBeforeType === WordCharacterClass.Regular) {
return false;
}
}
// Only consider auto closing the pair if a space follows or if another autoclosed pair follows
const characterAfter = lineText.charAt(position.column - 1);
if (characterAfter) {
let isBeforeCloseBrace = TypeOperations._isBeforeClosingBrace(config, ch, characterAfter);
if (!isBeforeCloseBrace && !shouldAutoCloseBefore(characterAfter)) {
return false;
}
}
if (!model.isCheapToTokenize(position.lineNumber)) {
// Do not force tokenization
return false;
}
model.forceTokenization(position.lineNumber);
const lineTokens = model.getLineTokens(position.lineNumber);
let shouldAutoClosePair = false;
try {
shouldAutoClosePair = LanguageConfigurationRegistry.shouldAutoClosePair(ch, lineTokens, position.column);
} catch (e) {
onUnexpectedError(e);
}
if (!shouldAutoClosePair) {
return false;
}
}
return true;
}