Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CComment/CComment.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ - (void)doMenuAction
NSString *commented = [self commentString:textView.textStorage.string range:&range];

if (commented != nil) {
[Xcode replaceCharactersInRange:range withString:commented];
[Xcode replaceCharactersInRange:range withString:commented andOptionEnabled:[self isOptionEnabled]];
}
}

Expand Down
2 changes: 1 addition & 1 deletion CComment/Xcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

+ (id)currentEditor;
+ (NSTextView *)textView;
+ (void)replaceCharactersInRange:(NSRange)range withString:(NSString *)aString;
+ (void)replaceCharactersInRange:(NSRange)range withString:(NSString *)aString andOptionEnabled:(BOOL)optionEnabled;
//+ (void)setupKeyBinding;

@end
4 changes: 3 additions & 1 deletion CComment/Xcode.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,16 @@ + (IDESourceCodeDocument *)sourceCodeDocument {
return nil;
}

+ (void)replaceCharactersInRange:(NSRange)range withString:(NSString *)aString
+ (void)replaceCharactersInRange:(NSRange)range withString:(NSString *)aString andOptionEnabled:(BOOL)optionEnabled
{
IDESourceCodeDocument * document = [self sourceCodeDocument];
if ( !document )
return;
[[document textStorage] beginEditing];
[[document textStorage] replaceCharactersInRange:range withString:aString withUndoManager:[document undoManager]];
[[document textStorage] endEditing];

[[self textView] setSelectedRange:NSMakeRange(range.location + aString.length - (optionEnabled ? 3 : 2), 0)];
}

@end