Skip to content

Commit 507316d

Browse files
authored
Add setting autoindent on paste (microsoft#250463)
* add setting autoindent on paste * setting value to false * remove ignoring of indentation when indenting line comments * adding back code
1 parent 554fc55 commit 507316d

File tree

4 files changed

+305
-289
lines changed

4 files changed

+305
-289
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,10 @@ export interface IEditorOptions {
507507
* Defaults to advanced.
508508
*/
509509
autoIndent?: 'none' | 'keep' | 'brackets' | 'advanced' | 'full';
510+
/**
511+
* Boolean which controls whether to autoindent on paste
512+
*/
513+
autoIndentOnPaste?: boolean;
510514
/**
511515
* Emulate selection behaviour of tab characters when using spaces for indentation.
512516
* This means selection will stick to tab stops.
@@ -5503,6 +5507,7 @@ export const enum EditorOption {
55035507
autoClosingOvertype,
55045508
autoClosingQuotes,
55055509
autoIndent,
5510+
autoIndentOnPaste,
55065511
automaticLayout,
55075512
autoSurround,
55085513
bracketPairColorization,
@@ -5774,6 +5779,10 @@ export const EditorOptions = {
57745779
description: nls.localize('autoIndent', "Controls whether the editor should automatically adjust the indentation when users type, paste, move or indent lines.")
57755780
}
57765781
)),
5782+
autoIndentOnPaste: register(new EditorBooleanOption(
5783+
EditorOption.autoIndentOnPaste, 'autoIndentOnPaste', false,
5784+
{ description: nls.localize('autoIndentOnPaste', "Controls whether the editor should automatically auto-indent the pasted content.") }
5785+
)),
57775786
automaticLayout: register(new EditorBooleanOption(
57785787
EditorOption.automaticLayout, 'automaticLayout', false,
57795788
)),

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

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

337338
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ export class AutoIndentOnPaste implements IEditorContribution {
386386
this.callOnModel.clear();
387387

388388
// we are disabled
389-
if (this.editor.getOption(EditorOption.autoIndent) < EditorAutoIndentStrategy.Full || !this.editor.getOption(EditorOption.formatOnPaste)) {
389+
if (!this.editor.getOption(EditorOption.autoIndentOnPaste) || this.editor.getOption(EditorOption.autoIndent) < EditorAutoIndentStrategy.Full) {
390390
return;
391391
}
392392

0 commit comments

Comments
 (0)