Skip to content

Commit 5457a12

Browse files
authored
Add setting autoIndentOnPasteWithinString (microsoft#250465)
* add setting autoindent on paste * setting value to false * autoindentonpastewithinstring
1 parent 274671e commit 5457a12

File tree

4 files changed

+306
-290
lines changed

4 files changed

+306
-290
lines changed

src/vs/editor/common/config/editorOptions.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,10 @@ export interface IEditorOptions {
511511
* Boolean which controls whether to autoindent on paste
512512
*/
513513
autoIndentOnPaste?: boolean;
514+
/**
515+
* Boolean which controls whether to autoindent on paste within a string when autoIndentOnPaste is enabled.
516+
*/
517+
autoIndentOnPasteWithinString?: boolean;
514518
/**
515519
* Emulate selection behaviour of tab characters when using spaces for indentation.
516520
* This means selection will stick to tab stops.
@@ -5508,6 +5512,7 @@ export const enum EditorOption {
55085512
autoClosingQuotes,
55095513
autoIndent,
55105514
autoIndentOnPaste,
5515+
autoIndentOnPasteWithinString,
55115516
automaticLayout,
55125517
autoSurround,
55135518
bracketPairColorization,
@@ -5783,6 +5788,10 @@ export const EditorOptions = {
57835788
EditorOption.autoIndentOnPaste, 'autoIndentOnPaste', false,
57845789
{ description: nls.localize('autoIndentOnPaste', "Controls whether the editor should automatically auto-indent the pasted content.") }
57855790
)),
5791+
autoIndentOnPasteWithinString: register(new EditorBooleanOption(
5792+
EditorOption.autoIndentOnPasteWithinString, 'autoIndentOnPasteWithinString', true,
5793+
{ description: nls.localize('autoIndentOnPasteWithinString', "Controls whether the editor should automatically auto-indent the pasted content when pasted within a string. This takes effect when autoIndentOnPaste is true.") }
5794+
)),
57865795
automaticLayout: register(new EditorBooleanOption(
57875796
EditorOption.automaticLayout, 'automaticLayout', false,
57885797
)),

src/vs/editor/common/standalone/standaloneEnums.ts

Lines changed: 146 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -189,150 +189,151 @@ export enum EditorOption {
189189
autoClosingQuotes = 12,
190190
autoIndent = 13,
191191
autoIndentOnPaste = 14,
192-
automaticLayout = 15,
193-
autoSurround = 16,
194-
bracketPairColorization = 17,
195-
guides = 18,
196-
codeLens = 19,
197-
codeLensFontFamily = 20,
198-
codeLensFontSize = 21,
199-
colorDecorators = 22,
200-
colorDecoratorsLimit = 23,
201-
columnSelection = 24,
202-
comments = 25,
203-
contextmenu = 26,
204-
copyWithSyntaxHighlighting = 27,
205-
cursorBlinking = 28,
206-
cursorSmoothCaretAnimation = 29,
207-
cursorStyle = 30,
208-
cursorSurroundingLines = 31,
209-
cursorSurroundingLinesStyle = 32,
210-
cursorWidth = 33,
211-
disableLayerHinting = 34,
212-
disableMonospaceOptimizations = 35,
213-
domReadOnly = 36,
214-
dragAndDrop = 37,
215-
dropIntoEditor = 38,
216-
experimentalEditContextEnabled = 39,
217-
emptySelectionClipboard = 40,
218-
experimentalGpuAcceleration = 41,
219-
experimentalWhitespaceRendering = 42,
220-
extraEditorClassName = 43,
221-
fastScrollSensitivity = 44,
222-
find = 45,
223-
fixedOverflowWidgets = 46,
224-
folding = 47,
225-
foldingStrategy = 48,
226-
foldingHighlight = 49,
227-
foldingImportsByDefault = 50,
228-
foldingMaximumRegions = 51,
229-
unfoldOnClickAfterEndOfLine = 52,
230-
fontFamily = 53,
231-
fontInfo = 54,
232-
fontLigatures = 55,
233-
fontSize = 56,
234-
fontWeight = 57,
235-
fontVariations = 58,
236-
formatOnPaste = 59,
237-
formatOnType = 60,
238-
glyphMargin = 61,
239-
gotoLocation = 62,
240-
hideCursorInOverviewRuler = 63,
241-
hover = 64,
242-
inDiffEditor = 65,
243-
inlineSuggest = 66,
244-
letterSpacing = 67,
245-
lightbulb = 68,
246-
lineDecorationsWidth = 69,
247-
lineHeight = 70,
248-
lineNumbers = 71,
249-
lineNumbersMinChars = 72,
250-
linkedEditing = 73,
251-
links = 74,
252-
matchBrackets = 75,
253-
minimap = 76,
254-
mouseStyle = 77,
255-
mouseWheelScrollSensitivity = 78,
256-
mouseWheelZoom = 79,
257-
multiCursorMergeOverlapping = 80,
258-
multiCursorModifier = 81,
259-
multiCursorPaste = 82,
260-
multiCursorLimit = 83,
261-
occurrencesHighlight = 84,
262-
occurrencesHighlightDelay = 85,
263-
overtypeCursorStyle = 86,
264-
overtypeOnPaste = 87,
265-
overviewRulerBorder = 88,
266-
overviewRulerLanes = 89,
267-
padding = 90,
268-
pasteAs = 91,
269-
parameterHints = 92,
270-
peekWidgetDefaultFocus = 93,
271-
placeholder = 94,
272-
definitionLinkOpensInPeek = 95,
273-
quickSuggestions = 96,
274-
quickSuggestionsDelay = 97,
275-
readOnly = 98,
276-
readOnlyMessage = 99,
277-
renameOnType = 100,
278-
renderControlCharacters = 101,
279-
renderFinalNewline = 102,
280-
renderLineHighlight = 103,
281-
renderLineHighlightOnlyWhenFocus = 104,
282-
renderValidationDecorations = 105,
283-
renderWhitespace = 106,
284-
revealHorizontalRightPadding = 107,
285-
roundedSelection = 108,
286-
rulers = 109,
287-
scrollbar = 110,
288-
scrollBeyondLastColumn = 111,
289-
scrollBeyondLastLine = 112,
290-
scrollPredominantAxis = 113,
291-
selectionClipboard = 114,
292-
selectionHighlight = 115,
293-
selectOnLineNumbers = 116,
294-
showFoldingControls = 117,
295-
showUnused = 118,
296-
snippetSuggestions = 119,
297-
smartSelect = 120,
298-
smoothScrolling = 121,
299-
stickyScroll = 122,
300-
stickyTabStops = 123,
301-
stopRenderingLineAfter = 124,
302-
suggest = 125,
303-
suggestFontSize = 126,
304-
suggestLineHeight = 127,
305-
suggestOnTriggerCharacters = 128,
306-
suggestSelection = 129,
307-
tabCompletion = 130,
308-
tabIndex = 131,
309-
unicodeHighlighting = 132,
310-
unusualLineTerminators = 133,
311-
useShadowDOM = 134,
312-
useTabStops = 135,
313-
wordBreak = 136,
314-
wordSegmenterLocales = 137,
315-
wordSeparators = 138,
316-
wordWrap = 139,
317-
wordWrapBreakAfterCharacters = 140,
318-
wordWrapBreakBeforeCharacters = 141,
319-
wordWrapColumn = 142,
320-
wordWrapOverride1 = 143,
321-
wordWrapOverride2 = 144,
322-
wrappingIndent = 145,
323-
wrappingStrategy = 146,
324-
showDeprecated = 147,
325-
inlayHints = 148,
326-
effectiveCursorStyle = 149,
327-
editorClassName = 150,
328-
pixelRatio = 151,
329-
tabFocusMode = 152,
330-
layoutInfo = 153,
331-
wrappingInfo = 154,
332-
defaultColorDecorators = 155,
333-
colorDecoratorsActivatedOn = 156,
334-
inlineCompletionsAccessibilityVerbose = 157,
335-
effectiveExperimentalEditContextEnabled = 158
192+
autoIndentOnPasteWithinString = 15,
193+
automaticLayout = 16,
194+
autoSurround = 17,
195+
bracketPairColorization = 18,
196+
guides = 19,
197+
codeLens = 20,
198+
codeLensFontFamily = 21,
199+
codeLensFontSize = 22,
200+
colorDecorators = 23,
201+
colorDecoratorsLimit = 24,
202+
columnSelection = 25,
203+
comments = 26,
204+
contextmenu = 27,
205+
copyWithSyntaxHighlighting = 28,
206+
cursorBlinking = 29,
207+
cursorSmoothCaretAnimation = 30,
208+
cursorStyle = 31,
209+
cursorSurroundingLines = 32,
210+
cursorSurroundingLinesStyle = 33,
211+
cursorWidth = 34,
212+
disableLayerHinting = 35,
213+
disableMonospaceOptimizations = 36,
214+
domReadOnly = 37,
215+
dragAndDrop = 38,
216+
dropIntoEditor = 39,
217+
experimentalEditContextEnabled = 40,
218+
emptySelectionClipboard = 41,
219+
experimentalGpuAcceleration = 42,
220+
experimentalWhitespaceRendering = 43,
221+
extraEditorClassName = 44,
222+
fastScrollSensitivity = 45,
223+
find = 46,
224+
fixedOverflowWidgets = 47,
225+
folding = 48,
226+
foldingStrategy = 49,
227+
foldingHighlight = 50,
228+
foldingImportsByDefault = 51,
229+
foldingMaximumRegions = 52,
230+
unfoldOnClickAfterEndOfLine = 53,
231+
fontFamily = 54,
232+
fontInfo = 55,
233+
fontLigatures = 56,
234+
fontSize = 57,
235+
fontWeight = 58,
236+
fontVariations = 59,
237+
formatOnPaste = 60,
238+
formatOnType = 61,
239+
glyphMargin = 62,
240+
gotoLocation = 63,
241+
hideCursorInOverviewRuler = 64,
242+
hover = 65,
243+
inDiffEditor = 66,
244+
inlineSuggest = 67,
245+
letterSpacing = 68,
246+
lightbulb = 69,
247+
lineDecorationsWidth = 70,
248+
lineHeight = 71,
249+
lineNumbers = 72,
250+
lineNumbersMinChars = 73,
251+
linkedEditing = 74,
252+
links = 75,
253+
matchBrackets = 76,
254+
minimap = 77,
255+
mouseStyle = 78,
256+
mouseWheelScrollSensitivity = 79,
257+
mouseWheelZoom = 80,
258+
multiCursorMergeOverlapping = 81,
259+
multiCursorModifier = 82,
260+
multiCursorPaste = 83,
261+
multiCursorLimit = 84,
262+
occurrencesHighlight = 85,
263+
occurrencesHighlightDelay = 86,
264+
overtypeCursorStyle = 87,
265+
overtypeOnPaste = 88,
266+
overviewRulerBorder = 89,
267+
overviewRulerLanes = 90,
268+
padding = 91,
269+
pasteAs = 92,
270+
parameterHints = 93,
271+
peekWidgetDefaultFocus = 94,
272+
placeholder = 95,
273+
definitionLinkOpensInPeek = 96,
274+
quickSuggestions = 97,
275+
quickSuggestionsDelay = 98,
276+
readOnly = 99,
277+
readOnlyMessage = 100,
278+
renameOnType = 101,
279+
renderControlCharacters = 102,
280+
renderFinalNewline = 103,
281+
renderLineHighlight = 104,
282+
renderLineHighlightOnlyWhenFocus = 105,
283+
renderValidationDecorations = 106,
284+
renderWhitespace = 107,
285+
revealHorizontalRightPadding = 108,
286+
roundedSelection = 109,
287+
rulers = 110,
288+
scrollbar = 111,
289+
scrollBeyondLastColumn = 112,
290+
scrollBeyondLastLine = 113,
291+
scrollPredominantAxis = 114,
292+
selectionClipboard = 115,
293+
selectionHighlight = 116,
294+
selectOnLineNumbers = 117,
295+
showFoldingControls = 118,
296+
showUnused = 119,
297+
snippetSuggestions = 120,
298+
smartSelect = 121,
299+
smoothScrolling = 122,
300+
stickyScroll = 123,
301+
stickyTabStops = 124,
302+
stopRenderingLineAfter = 125,
303+
suggest = 126,
304+
suggestFontSize = 127,
305+
suggestLineHeight = 128,
306+
suggestOnTriggerCharacters = 129,
307+
suggestSelection = 130,
308+
tabCompletion = 131,
309+
tabIndex = 132,
310+
unicodeHighlighting = 133,
311+
unusualLineTerminators = 134,
312+
useShadowDOM = 135,
313+
useTabStops = 136,
314+
wordBreak = 137,
315+
wordSegmenterLocales = 138,
316+
wordSeparators = 139,
317+
wordWrap = 140,
318+
wordWrapBreakAfterCharacters = 141,
319+
wordWrapBreakBeforeCharacters = 142,
320+
wordWrapColumn = 143,
321+
wordWrapOverride1 = 144,
322+
wordWrapOverride2 = 145,
323+
wrappingIndent = 146,
324+
wrappingStrategy = 147,
325+
showDeprecated = 148,
326+
inlayHints = 149,
327+
effectiveCursorStyle = 150,
328+
editorClassName = 151,
329+
pixelRatio = 152,
330+
tabFocusMode = 153,
331+
layoutInfo = 154,
332+
wrappingInfo = 155,
333+
defaultColorDecorators = 156,
334+
colorDecoratorsActivatedOn = 157,
335+
inlineCompletionsAccessibilityVerbose = 158,
336+
effectiveExperimentalEditContextEnabled = 159
336337
}
337338

338339
/**
@@ -991,4 +992,4 @@ export enum WrappingIndent {
991992
* DeepIndent => wrapped lines get +2 indentation toward the parent.
992993
*/
993994
DeepIndent = 3
994-
}
995+
}

src/vs/editor/contrib/indentation/browser/indentation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ export class AutoIndentOnPaste implements IEditorContribution {
414414
if (containsOnlyWhitespace) {
415415
return;
416416
}
417-
if (isStartOrEndInString(model, range)) {
417+
if (!this.editor.getOption(EditorOption.autoIndentOnPasteWithinString) && isStartOrEndInString(model, range)) {
418418
return;
419419
}
420420
if (!model.tokenization.isCheapToTokenize(range.getStartPosition().lineNumber)) {

0 commit comments

Comments
 (0)