How to stop clang-format break fields seperator(::)? - clang-format

clang-format version 15.0.6
Question> Which settings I can use to get the expected format shown below?
Thank you
What I see:
auto amount =
msg[AAAAAAAAAAAAAAAAAAAAAAAAA::
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb]
.get<double>();
What I expect:
auto amount =
msg[AAAAAAAAAAAAAAAAAAAAAAAAA::bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb]
.get<double>();
My current settings for Break:
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: Always
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ObjCBreakBeforeNestedBlockParam: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10

I think you haven't set the option ColumnLimit. By default, it is set to 80. Try setting that manually, or if you don't want it to wrap, then set it to 0.
Without setting ColumnLimit:
auto amount =
msg[AAAAAAAAAAAAAAAAAAAAAAAAA::
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb]
.get<double>();
After setting ColumnLimit: 0:
auto amount =
msg[AAAAAAAAAAAAAAAAAAAAAAAAA::bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb]
.get<double>();

Related

iOS Charts Disable Zoom

How do you disable zoom for iOS Charts but not completely stop user interaction? For example, still using the highlight tap. This takes care of the zoom, but it disables everything else as well.
chartView.userInteractionEnabled = false
To disable zoom, but not impact other chart interaction, make these adjustments:
chartView.doubleTapToZoomEnabled = false
chartView.pinchZoomEnabled = false
chartView.scaleXEnabled = false
chartView.scaleYEnabled = false

Search bar looks weird if width is less than 116

I am trying to create square search bar but when I set width less than 116, search icon and textfield area moved out of search bar. Please refer first search bar of screenshot.
I have fixed this issue by adding following code to set constraints manually for searchTextField.
searchBar.searchTextField.translatesAutoresizingMaskIntoConstraints = false
searchBar.searchTextField.leftAnchor.constraint(equalTo: searchBar.leftAnchor, constant: 8).isActive = true
searchBar.searchTextField.rightAnchor.constraint(equalTo: searchBar.rightAnchor, constant: -8).isActive = true
searchBar.searchTextField.topAnchor.constraint(equalTo: searchBar.topAnchor, constant: 6).isActive = true
searchBar.searchTextField.bottomAnchor.constraint(equalTo: searchBar.bottomAnchor, constant: -6).isActive = true
While expanding width, I marked translatesAutoresizingMaskIntoConstraints as true.
searchBar.searchTextField.translatesAutoresizingMaskIntoConstraints = true

iOS - Change constraints in runtime works only first time

I have this code, that changle constraint based on visibility of element:
if (self.collectionView.isHidden){
controller.view.bottomAnchor.constraint(equalTo: self.collectionView.topAnchor).isActive = false
controller.view.bottomAnchor.constraint(equalTo: self.view2.topAnchor).isActive = true
}
else {
controller.view.bottomAnchor.constraint(equalTo: self.collectionView.topAnchor).isActive = true
controller.view.bottomAnchor.constraint(equalTo: self.view2.topAnchor).isActive = false
}
If I do this after collectionView.isHidden is set to true, it works. However, after I set collectionView.isHidden = true and call this code, it no longer works and controller.view is still attached to the top of view2.
There is also an height constraint attached to collectionView ant ist values is 50.
I also have tried manually setting collectionView.frame.size.height = 50 (or some other default value) because without this, height of collectionView.frame.size.height is zero. But not works. I have tried call collectionView.updateConstraints(), but it has no effect either.
So, I think you are setting a new constraint every time you call the function, you are not really removing the previous one.
Usually when I need this kind of logic I keep a reference to the constraint so that I can activate/deactivate it later, like this:
var controllerBottomAnchor: NSLayoutConstraint?
Then I assign it like so:
controllerBottomAnchor = controller.view.bottomAnchor.constraint(equalTo: self.collectionView.topAnchor)
controllerBottomAnchor?.isActive = true
Once I need to change it I just use the reference:
controllerBottomAnchor?.isActive = false
I typically use it for width and height anchors.

Clang-Format blocks and ColumnLimit 0

I am having some trouble with clang-format and blocks. I'd like to maintain the following format for method invocation with trailing blocks:
[self presentViewController:alertController animated:YES completion:^{
NSLog(#"Output");
// Do something
}];
I have set ColumnLimit to 0, which works everywhere, but it has the side effect of not formatting anything within the block (if statements, other invocation, etc.). The only way to get code inside blocks formatted, that I can find, is to set ColumnLimit to > 0, however, even if I set it to something huge like 100000, it adds breaks to every argument, which I do not want:
[self presentViewController:alertController
animated:YES
completion:^{
NSLog(#"Output");
// Do something
}];
So, the combination I want is for code within blocks to be properly formatted while not touching anything else about the method invocation.
My clang-format config:
Language: Cpp
ColumnLimit: 0
AllowShortBlocksOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortLoopsOnASingleLine: false
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 1
IndentWidth: 4
TabWidth: 4
UseTab: Never
PointerAlignment: Right
DerivePointerAlignment: false
ObjCSpaceAfterProperty: true
BreakBeforeBraces: Stroustrup
AllowShortIfStatementsOnASingleLine: false
BreakBeforeTernaryOperators: false
IndentCaseLabels: true
AllowShortCaseLabelsOnASingleLine: false
AlignTrailingComments: true
BinPackParameters: false
BinPackArguments: false
AllowShortFunctionsOnASingleLine: false
IndentWrappedFunctionNames: false
ObjCSpaceBeforeProtocolList: true
SpacesInParentheses: false
SpacesInAngles: false
SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: true
SpaceBeforeAssignmentOperators: true
SpacesBeforeTrailingComments: 1
ObjCBlockIndentWidth: 4
Clang format version is 3.6.
Any help would be great, not sure if this is possible to achieve.

minPadding doesn't work

I have the chart
Now if data is equal 1 then the line is hard to see below image
I write:
minPadding: 0.08,
maxPadding: 0.08,
but this doesn't work
How to shift the graph down?
The problem is that when you you set minPadding to 0.08 you get the padding, but using tickPositioner starting on 1 it looks like not, because you need more space to show the padding.
So change it's start point from 1 to 0.
tickPositioner: function(min, max) {
return [0,10,20,30,40];
}
demo
Update - According to the comment:
So set startOnTick to false and min to 0, this will force to show the padding because the min is 0.
demo1 demo2
It should be false by default but it seems that if you explicitly set
startOnTick: false
Then you get the desired spacing:
Updated fiddle here.

Resources