@@ -73,7 +73,7 @@ class EditTextView: NSTextView, NSTextFinderClient, NSSharingServicePickerDelega
7373 let oneCharSize = ( " a " as NSString ) . size ( withAttributes: tagAttributes)
7474
7575 let height = oneCharSize. height > tagRect. size. height ? tagRect. size. height : oneCharSize. height
76- let tagBorderRect = NSRect ( origin: CGPoint ( x: tagRect. origin. x- oneCharSize. width*0. 25 , y: tagRect. origin. y) , size: CGSize ( width: tagRect. size. width+ oneCharSize. width*0. 33 , height: height) )
76+ let tagBorderRect = NSRect ( origin: CGPoint ( x: tagRect. origin. x- oneCharSize. width*0. 1 , y: tagRect. origin. y) , size: CGSize ( width: tagRect. size. width+ oneCharSize. width*0. 3 , height: height) )
7777
7878 NSGraphicsContext . saveGraphicsState ( )
7979
@@ -96,12 +96,17 @@ class EditTextView: NSTextView, NSTextFinderClient, NSSharingServicePickerDelega
9696// path.transform(using: transform as AffineTransform)
9797// path.stroke()
9898
99- let resFont = NSFontManager . shared. convert ( font, toSize: font. pointSize - 1 )
99+ let resFont = NSFontManager . shared. convert ( font, toSize: font. pointSize)
100100 let dict = NSMutableDictionary ( dictionary: tagAttributes)
101101
102- dict. addEntries ( from: [ NSAttributedString . Key. font: resFont, NSAttributedString . Key. foregroundColor: textColor] )
102+ dict. addEntries ( from: [
103+ NSAttributedString . Key. font: resFont,
104+ NSAttributedString . Key. foregroundColor: textColor
105+ ] )
103106 dict. removeObject ( forKey: NSAttributedString . Key. link)
104- ( tag as NSString ) . draw ( in: tagRect, withAttributes: ( dict as! [ NSAttributedString . Key : Any ] ) )
107+
108+ let newRect = tagRect. offsetBy ( dx: 0 , dy: - 1 )
109+ ( tag as NSString ) . draw ( in: newRect, withAttributes: ( dict as! [ NSAttributedString . Key : Any ] ) )
105110
106111 NSGraphicsContext . restoreGraphicsState ( )
107112 }
@@ -446,6 +451,31 @@ class EditTextView: NSTextView, NSTextFinderClient, NSSharingServicePickerDelega
446451 return replacementRange
447452 }
448453
454+ if UserDefaultsManagement . inlineTags {
455+ var location = distance
456+ var length = 0
457+
458+ while true {
459+ if location - 1 < 0 {
460+ break
461+ }
462+
463+ let scanRange = NSRange ( location: location - 1 , length: 1 )
464+ let char = textStorage? . attributedSubstring ( from: scanRange) . string
465+
466+ if char? . isWhitespace != nil {
467+ break
468+ }
469+
470+ if char == " # " {
471+ return NSRange ( location: location, length: length)
472+ }
473+
474+ length += 1
475+ location = location - 1
476+ }
477+ }
478+
449479 return super. rangeForUserCompletion
450480 }
451481
0 commit comments