mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode 91e99652cd5fcfc072387c64e151b435e39e8dcf (#6962)
This commit is contained in:
@@ -558,6 +558,17 @@ const editorConfiguration: IConfigurationNode = {
|
||||
'default': EDITOR_DEFAULTS.autoClosingQuotes,
|
||||
'description': nls.localize('autoClosingQuotes', "Controls whether the editor should automatically close quotes after the user adds an opening quote.")
|
||||
},
|
||||
'editor.autoClosingOvertype': {
|
||||
type: 'string',
|
||||
enum: ['always', 'auto', 'never'],
|
||||
enumDescriptions: [
|
||||
nls.localize('editor.autoClosingOvertype.always', "Always type over closing quotes or brackets."),
|
||||
nls.localize('editor.autoClosingOvertype.auto', "Type over closing quotes or brackets only if they were automatically inserted."),
|
||||
nls.localize('editor.autoClosingOvertype.never', "Never type over closing quotes or brackets."),
|
||||
],
|
||||
'default': EDITOR_DEFAULTS.autoClosingOvertype,
|
||||
'description': nls.localize('autoClosingOvertype', "Controls whether the editor should type over closing quotes or brackets.")
|
||||
},
|
||||
'editor.autoSurround': {
|
||||
type: 'string',
|
||||
enum: ['languageDefined', 'brackets', 'quotes', 'never'],
|
||||
|
||||
@@ -108,6 +108,11 @@ export type EditorAutoClosingStrategy = 'always' | 'languageDefined' | 'beforeWh
|
||||
*/
|
||||
export type EditorAutoSurroundStrategy = 'languageDefined' | 'quotes' | 'brackets' | 'never';
|
||||
|
||||
/**
|
||||
* Configuration options for typing over closing quotes or brackets
|
||||
*/
|
||||
export type EditorAutoClosingOvertypeStrategy = 'always' | 'auto' | 'never';
|
||||
|
||||
/**
|
||||
* Configuration options for editor minimap
|
||||
*/
|
||||
@@ -544,6 +549,10 @@ export interface IEditorOptions {
|
||||
* Defaults to language defined behavior.
|
||||
*/
|
||||
autoClosingQuotes?: EditorAutoClosingStrategy;
|
||||
/**
|
||||
* Options for typing over closing quotes or brackets.
|
||||
*/
|
||||
autoClosingOvertype?: EditorAutoClosingOvertypeStrategy;
|
||||
/**
|
||||
* Options for auto surrounding.
|
||||
* Defaults to always allowing auto surrounding.
|
||||
@@ -1079,6 +1088,7 @@ export interface IValidatedEditorOptions {
|
||||
readonly wordWrapBreakObtrusiveCharacters: string;
|
||||
readonly autoClosingBrackets: EditorAutoClosingStrategy;
|
||||
readonly autoClosingQuotes: EditorAutoClosingStrategy;
|
||||
readonly autoClosingOvertype: EditorAutoClosingOvertypeStrategy;
|
||||
readonly autoSurround: EditorAutoSurroundStrategy;
|
||||
readonly autoIndent: boolean;
|
||||
readonly dragAndDrop: boolean;
|
||||
@@ -1117,6 +1127,7 @@ export class InternalEditorOptions {
|
||||
readonly wordSeparators: string;
|
||||
readonly autoClosingBrackets: EditorAutoClosingStrategy;
|
||||
readonly autoClosingQuotes: EditorAutoClosingStrategy;
|
||||
readonly autoClosingOvertype: EditorAutoClosingOvertypeStrategy;
|
||||
readonly autoSurround: EditorAutoSurroundStrategy;
|
||||
readonly autoIndent: boolean;
|
||||
readonly useTabStops: boolean;
|
||||
@@ -1147,6 +1158,7 @@ export class InternalEditorOptions {
|
||||
wordSeparators: string;
|
||||
autoClosingBrackets: EditorAutoClosingStrategy;
|
||||
autoClosingQuotes: EditorAutoClosingStrategy;
|
||||
autoClosingOvertype: EditorAutoClosingOvertypeStrategy;
|
||||
autoSurround: EditorAutoSurroundStrategy;
|
||||
autoIndent: boolean;
|
||||
useTabStops: boolean;
|
||||
@@ -1172,6 +1184,7 @@ export class InternalEditorOptions {
|
||||
this.wordSeparators = source.wordSeparators;
|
||||
this.autoClosingBrackets = source.autoClosingBrackets;
|
||||
this.autoClosingQuotes = source.autoClosingQuotes;
|
||||
this.autoClosingOvertype = source.autoClosingOvertype;
|
||||
this.autoSurround = source.autoSurround;
|
||||
this.autoIndent = source.autoIndent;
|
||||
this.useTabStops = source.useTabStops;
|
||||
@@ -1203,6 +1216,7 @@ export class InternalEditorOptions {
|
||||
&& this.wordSeparators === other.wordSeparators
|
||||
&& this.autoClosingBrackets === other.autoClosingBrackets
|
||||
&& this.autoClosingQuotes === other.autoClosingQuotes
|
||||
&& this.autoClosingOvertype === other.autoClosingOvertype
|
||||
&& this.autoSurround === other.autoSurround
|
||||
&& this.autoIndent === other.autoIndent
|
||||
&& this.useTabStops === other.useTabStops
|
||||
@@ -1235,6 +1249,7 @@ export class InternalEditorOptions {
|
||||
wordSeparators: (this.wordSeparators !== newOpts.wordSeparators),
|
||||
autoClosingBrackets: (this.autoClosingBrackets !== newOpts.autoClosingBrackets),
|
||||
autoClosingQuotes: (this.autoClosingQuotes !== newOpts.autoClosingQuotes),
|
||||
autoClosingOvertype: (this.autoClosingOvertype !== newOpts.autoClosingOvertype),
|
||||
autoSurround: (this.autoSurround !== newOpts.autoSurround),
|
||||
autoIndent: (this.autoIndent !== newOpts.autoIndent),
|
||||
useTabStops: (this.useTabStops !== newOpts.useTabStops),
|
||||
@@ -1640,6 +1655,7 @@ export interface IConfigurationChangedEvent {
|
||||
readonly wordSeparators: boolean;
|
||||
readonly autoClosingBrackets: boolean;
|
||||
readonly autoClosingQuotes: boolean;
|
||||
readonly autoClosingOvertype: boolean;
|
||||
readonly autoSurround: boolean;
|
||||
readonly autoIndent: boolean;
|
||||
readonly useTabStops: boolean;
|
||||
@@ -1852,6 +1868,7 @@ export class EditorOptionsValidator {
|
||||
wordWrapBreakObtrusiveCharacters: _string(opts.wordWrapBreakObtrusiveCharacters, defaults.wordWrapBreakObtrusiveCharacters),
|
||||
autoClosingBrackets,
|
||||
autoClosingQuotes,
|
||||
autoClosingOvertype: _stringSet<EditorAutoClosingOvertypeStrategy>(opts.autoClosingOvertype, defaults.autoClosingOvertype, ['always', 'auto', 'never']),
|
||||
autoSurround,
|
||||
autoIndent: _boolean(opts.autoIndent, defaults.autoIndent),
|
||||
dragAndDrop: _boolean(opts.dragAndDrop, defaults.dragAndDrop),
|
||||
@@ -2148,7 +2165,6 @@ export class EditorOptionsValidator {
|
||||
export class InternalEditorOptionsFactory {
|
||||
|
||||
private static _tweakValidatedOptions(opts: IValidatedEditorOptions, accessibilitySupport: AccessibilitySupport): IValidatedEditorOptions {
|
||||
const accessibilityIsOn = (accessibilitySupport === AccessibilitySupport.Enabled);
|
||||
const accessibilityIsOff = (accessibilitySupport === AccessibilitySupport.Disabled);
|
||||
return {
|
||||
inDiffEditor: opts.inDiffEditor,
|
||||
@@ -2168,6 +2184,7 @@ export class InternalEditorOptionsFactory {
|
||||
wordWrapBreakObtrusiveCharacters: opts.wordWrapBreakObtrusiveCharacters,
|
||||
autoClosingBrackets: opts.autoClosingBrackets,
|
||||
autoClosingQuotes: opts.autoClosingQuotes,
|
||||
autoClosingOvertype: opts.autoClosingOvertype,
|
||||
autoSurround: opts.autoSurround,
|
||||
autoIndent: opts.autoIndent,
|
||||
dragAndDrop: opts.dragAndDrop,
|
||||
@@ -2244,7 +2261,7 @@ export class InternalEditorOptionsFactory {
|
||||
selectionHighlight: opts.contribInfo.selectionHighlight,
|
||||
occurrencesHighlight: opts.contribInfo.occurrencesHighlight,
|
||||
codeLens: opts.contribInfo.codeLens,
|
||||
folding: (accessibilityIsOn ? false : opts.contribInfo.folding), // DISABLED WHEN SCREEN READER IS ATTACHED
|
||||
folding: opts.contribInfo.folding,
|
||||
foldingStrategy: opts.contribInfo.foldingStrategy,
|
||||
showFoldingControls: opts.contribInfo.showFoldingControls,
|
||||
matchBrackets: opts.contribInfo.matchBrackets,
|
||||
@@ -2396,6 +2413,7 @@ export class InternalEditorOptionsFactory {
|
||||
wordSeparators: opts.wordSeparators,
|
||||
autoClosingBrackets: opts.autoClosingBrackets,
|
||||
autoClosingQuotes: opts.autoClosingQuotes,
|
||||
autoClosingOvertype: opts.autoClosingOvertype,
|
||||
autoSurround: opts.autoSurround,
|
||||
autoIndent: opts.autoIndent,
|
||||
useTabStops: opts.useTabStops,
|
||||
@@ -2635,6 +2653,7 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
|
||||
wordWrapBreakObtrusiveCharacters: '.',
|
||||
autoClosingBrackets: 'languageDefined',
|
||||
autoClosingQuotes: 'languageDefined',
|
||||
autoClosingOvertype: 'auto',
|
||||
autoSurround: 'languageDefined',
|
||||
autoIndent: true,
|
||||
dragAndDrop: true,
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import { CharCode } from 'vs/base/common/charCode';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { EditorAutoClosingStrategy, EditorAutoSurroundStrategy, IConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions';
|
||||
import { EditorAutoClosingStrategy, EditorAutoSurroundStrategy, IConfigurationChangedEvent, EditorAutoClosingOvertypeStrategy } from 'vs/editor/common/config/editorOptions';
|
||||
import { CursorChangeReason } from 'vs/editor/common/controller/cursorEvents';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
@@ -99,6 +99,7 @@ export class CursorConfiguration {
|
||||
public readonly multiCursorMergeOverlapping: boolean;
|
||||
public readonly autoClosingBrackets: EditorAutoClosingStrategy;
|
||||
public readonly autoClosingQuotes: EditorAutoClosingStrategy;
|
||||
public readonly autoClosingOvertype: EditorAutoClosingOvertypeStrategy;
|
||||
public readonly autoSurround: EditorAutoSurroundStrategy;
|
||||
public readonly autoIndent: boolean;
|
||||
public readonly autoClosingPairsOpen2: Map<string, StandardAutoClosingPairConditional[]>;
|
||||
@@ -117,6 +118,7 @@ export class CursorConfiguration {
|
||||
|| e.multiCursorMergeOverlapping
|
||||
|| e.autoClosingBrackets
|
||||
|| e.autoClosingQuotes
|
||||
|| e.autoClosingOvertype
|
||||
|| e.autoSurround
|
||||
|| e.useTabStops
|
||||
|| e.lineHeight
|
||||
@@ -146,6 +148,7 @@ export class CursorConfiguration {
|
||||
this.multiCursorMergeOverlapping = c.multiCursorMergeOverlapping;
|
||||
this.autoClosingBrackets = c.autoClosingBrackets;
|
||||
this.autoClosingQuotes = c.autoClosingQuotes;
|
||||
this.autoClosingOvertype = c.autoClosingOvertype;
|
||||
this.autoSurround = c.autoSurround;
|
||||
this.autoIndent = c.autoIndent;
|
||||
|
||||
|
||||
@@ -431,10 +431,8 @@ export class TypeOperations {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static _isAutoClosingCloseCharType(config: CursorConfiguration, model: ITextModel, selections: Selection[], autoClosedCharacters: Range[], ch: string): boolean {
|
||||
const autoCloseConfig = isQuote(ch) ? config.autoClosingQuotes : config.autoClosingBrackets;
|
||||
|
||||
if (autoCloseConfig === 'never') {
|
||||
private static _isAutoClosingOvertype(config: CursorConfiguration, model: ITextModel, selections: Selection[], autoClosedCharacters: Range[], ch: string): boolean {
|
||||
if (config.autoClosingOvertype === 'never') {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -458,23 +456,25 @@ export class TypeOperations {
|
||||
}
|
||||
|
||||
// Must over-type a closing character typed by the editor
|
||||
let found = false;
|
||||
for (let j = 0, lenJ = autoClosedCharacters.length; j < lenJ; j++) {
|
||||
const autoClosedCharacter = autoClosedCharacters[j];
|
||||
if (position.lineNumber === autoClosedCharacter.startLineNumber && position.column === autoClosedCharacter.startColumn) {
|
||||
found = true;
|
||||
break;
|
||||
if (config.autoClosingOvertype === 'auto') {
|
||||
let found = false;
|
||||
for (let j = 0, lenJ = autoClosedCharacters.length; j < lenJ; j++) {
|
||||
const autoClosedCharacter = autoClosedCharacters[j];
|
||||
if (position.lineNumber === autoClosedCharacter.startLineNumber && position.column === autoClosedCharacter.startColumn) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static _runAutoClosingCloseCharType(prevEditOperationType: EditOperationType, config: CursorConfiguration, model: ITextModel, selections: Selection[], ch: string): EditOperationResult {
|
||||
private static _runAutoClosingOvertype(prevEditOperationType: EditOperationType, config: CursorConfiguration, model: ITextModel, selections: Selection[], ch: string): EditOperationResult {
|
||||
let commands: ICommand[] = [];
|
||||
for (let i = 0, len = selections.length; i < len; i++) {
|
||||
const selection = selections[i];
|
||||
@@ -765,7 +765,7 @@ export class TypeOperations {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (this._isAutoClosingCloseCharType(config, model, selections, autoClosedCharacters, ch)) {
|
||||
if (this._isAutoClosingOvertype(config, model, selections, autoClosedCharacters, ch)) {
|
||||
// Unfortunately, the close character is at this point "doubled", so we need to delete it...
|
||||
const commands = selections.map(s => new ReplaceCommand(new Range(s.positionLineNumber, s.positionColumn, s.positionLineNumber, s.positionColumn + 1), '', false));
|
||||
return new EditOperationResult(EditOperationType.Typing, commands, {
|
||||
@@ -813,8 +813,8 @@ export class TypeOperations {
|
||||
}
|
||||
}
|
||||
|
||||
if (this._isAutoClosingCloseCharType(config, model, selections, autoClosedCharacters, ch)) {
|
||||
return this._runAutoClosingCloseCharType(prevEditOperationType, config, model, selections, ch);
|
||||
if (this._isAutoClosingOvertype(config, model, selections, autoClosedCharacters, ch)) {
|
||||
return this._runAutoClosingOvertype(prevEditOperationType, config, model, selections, ch);
|
||||
}
|
||||
|
||||
const autoClosingPairOpenCharType = this._isAutoClosingOpenCharType(config, model, selections, ch, true);
|
||||
|
||||
@@ -39,7 +39,8 @@ const enum WordType {
|
||||
export const enum WordNavigationType {
|
||||
WordStart = 0,
|
||||
WordStartFast = 1,
|
||||
WordEnd = 2
|
||||
WordEnd = 2,
|
||||
WordAccessibility = 3 // Respect chrome defintion of a word
|
||||
}
|
||||
|
||||
export class WordOperations {
|
||||
@@ -202,6 +203,18 @@ export class WordOperations {
|
||||
return new Position(lineNumber, prevWordOnLine ? prevWordOnLine.start + 1 : 1);
|
||||
}
|
||||
|
||||
if (wordNavigationType === WordNavigationType.WordAccessibility) {
|
||||
while (
|
||||
prevWordOnLine
|
||||
&& prevWordOnLine.wordType === WordType.Separator
|
||||
) {
|
||||
// Skip over words made up of only separators
|
||||
prevWordOnLine = WordOperations._findPreviousWordOnLine(wordSeparators, model, new Position(lineNumber, prevWordOnLine.start + 1));
|
||||
}
|
||||
|
||||
return new Position(lineNumber, prevWordOnLine ? prevWordOnLine.start + 1 : 1);
|
||||
}
|
||||
|
||||
// We are stopping at the ending of words
|
||||
|
||||
if (prevWordOnLine && column <= prevWordOnLine.end + 1) {
|
||||
@@ -270,6 +283,21 @@ export class WordOperations {
|
||||
nextWordOnLine = WordOperations._findNextWordOnLine(wordSeparators, model, new Position(lineNumber, nextWordOnLine.end + 1));
|
||||
}
|
||||
}
|
||||
if (nextWordOnLine) {
|
||||
column = nextWordOnLine.end + 1;
|
||||
} else {
|
||||
column = model.getLineMaxColumn(lineNumber);
|
||||
}
|
||||
} else if (wordNavigationType === WordNavigationType.WordAccessibility) {
|
||||
|
||||
while (
|
||||
nextWordOnLine
|
||||
&& nextWordOnLine.wordType === WordType.Separator
|
||||
) {
|
||||
// Skip over a word made up of one single separator
|
||||
nextWordOnLine = WordOperations._findNextWordOnLine(wordSeparators, model, new Position(lineNumber, nextWordOnLine.end + 1));
|
||||
}
|
||||
|
||||
if (nextWordOnLine) {
|
||||
column = nextWordOnLine.end + 1;
|
||||
} else {
|
||||
@@ -617,4 +645,4 @@ export class WordPartOperations extends WordOperations {
|
||||
|
||||
function enforceDefined<T>(arr: Array<T | undefined | null>): T[] {
|
||||
return <T[]>arr.filter(el => Boolean(el));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ export function tokenizeLineToHTML(text: string, viewLineTokens: IViewLineTokens
|
||||
break;
|
||||
|
||||
case CharCode.Space:
|
||||
partContent += ' ';
|
||||
partContent += ' ';
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user