Sarrus1 / sourcepawn-studio

VSCode extension for SourcePawn scripting
https://sarrus1.github.io/sourcepawn-studio/
MIT License
143 stars 22 forks source link

Manual Fix for "public" Formatting Not Working #165

Closed repository closed 2 years ago

repository commented 2 years ago

Basic info

Further Information

I'm having a similar issue to #155, except I'm not able to get it working. See: https://t89.s3-us-west-1.amazonaws.com/2021/12/ZSAt5H46/unknown.mp4

Formatting options

{
  "sourcepawn.formatterSettings": [
    "BasedOnStyle: Google",
    "AlignArrayOfStructures: Left",
    "AlignConsecutiveAssignments: AcrossComments",
    "AlignConsecutiveBitFields: AcrossComments",
    "AlignConsecutiveDeclarations: AcrossComments",
    "AlignConsecutiveMacros: AcrossComments",
    "AlignOperands: AlignAfterOperator",
    "AllowShortBlocksOnASingleLine: Always",
    "AllowShortCaseLabelsOnASingleLine: true",
    "AllowShortFunctionsOnASingleLine: Inline",
    "AllowShortIfStatementsOnASingleLine: AllIfsAndElse",
    "AllowShortLambdasOnASingleLine: All",
    "AllowShortLoopsOnASingleLine: true",
    "BreakBeforeBinaryOperators: NonAssignment",
    "BreakBeforeBraces: Attach",
    "BraceWrapping: { AfterClass: false",
    "AfterCaseLabel: false",
    "AfterControlStatement: Never",
    "AfterEnum: false",
    "AfterFunction: false",
    "AfterNamespace: false",
    "AfterObjCDeclaration: false",
    "AfterStruct: false",
    "AfterUnion: false",
    "AfterExternBlock: false",
    "BeforeCatch: false",
    "BeforeElse: false",
    "BeforeLambdaBody: false",
    "BeforeWhile: false",
    "IndentBraces: false",
    "SplitEmptyFunction: false",
    "SplitEmptyRecord: false",
    "SplitEmptyNamespace: false }",
    "BreakBeforeConceptDeclarations: false",
    "BreakStringLiterals: false",
    "BreakBeforeTernaryOperators: true",
    "BreakConstructorInitializers: AfterColon",
    "BreakInheritanceList: AfterComma",
    "CommentPragmas: '@'",
    "ReflowComments: true",
    "MaxEmptyLinesToKeep: 1",
    "NamespaceIndentation: All",
    "DeriveLineEnding: true",
    "DerivePointerAlignment: false",
    "EmptyLineBeforeAccessModifier: LogicalBlock",
    "FixNamespaceComments: true",
    "CompactNamespaces: false",
    "ConstructorInitializerIndentWidth: ${TabSize}",
    "ContinuationIndentWidth: ${TabSize}",
    "Cpp11BracedListStyle: false",
    "SortIncludes: CaseInsensitive",
    "IncludeBlocks: Preserve",
    "SpaceAfterCStyleCast: false",
    "SpaceAfterLogicalNot: false",
    "SpaceBeforeAssignmentOperators: true",
    "SpaceBeforeCaseColon: false",
    "SpaceBeforeCpp11BracedList: false",
    "SpaceInEmptyBlock: false",
    "SpacesInCStyleCastParentheses: false",
    "SpaceInEmptyParentheses: false",
    "SpacesInConditionalStatement: false",
    "SpacesInContainerLiterals: true",
    "SpacesInParentheses: false",
    "SpacesInSquareBrackets: false",
    "SpaceBeforeRangeBasedForLoopColon: true",
    "SpaceBeforeSquareBrackets: false",
    "SpaceBeforeCtorInitializerColon: true",
    "SpaceBeforeInheritanceColon: true",
    "SpaceBeforeParens: ControlStatementsExceptControlMacros",
    "IndentPPDirectives: BeforeHash",
    "IndentAccessModifiers: false",
    "IndentCaseBlocks: false",
    "IndentCaseLabels: true",
    "ColumnLimit: 0",
    "IndentRequires: true",
    "IndentExternBlock: Indent",
    "IndentGotoLabels: false",
    "IndentWidth: ${TabSize}",
    "IndentWrappedFunctionNames: true",
    "Language: Cpp",
    "SpacesBeforeTrailingComments: ${TabSize}",
    "TabWidth: ${TabSize}",
    "UseTab: Never"
  ]
}

To Reproduce

Format

#include <sourcemod>

public void OnPluginStart() {
  PrintToServer("Test");
}

Expected behaviour

"public" is on the same line as the function

Error messages

Occurs when saving, but doesn't appear relevant to the formatting issue

 ERR [Extension Host] TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''
    at normalizeSpawnArguments (child_process.js:423:11)
    at spawn (child_process.js:568:13)
    at execFile (child_process.js:246:17)
    at execFile (electron/js2c/asar_bundle.js:5:2242)
    at Timeout._onTimeout (c:\Users\me\.vscode\extensions\sarrus.sourcepawn-vscode-3.0.0\client\src\spLinter.ts:157:9)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)
Sarrus1 commented 2 years ago

It appears that clang-format adds a carriage return (U+000D) before line breaks depending on the configuration. This was breaking the fix.

repository commented 2 years ago

Thanks for quick fix đź‘Ť