@@ -264,11 +264,81 @@ const (
264264// possible orientations.
265265func (c * Canvas ) Lines () []Line {
266266
267+ horizontalMidlines := c .getLinesForSegment ('-' )
268+
267269 diagUpLines := c .getLinesForSegment ('/' )
270+ for i , l := range diagUpLines {
271+ // /_
272+ if c .runeAt (l .start .east ()) == '_' {
273+ diagUpLines [i ].needsTinyNudgingLeft = true
274+ }
275+
276+ // _
277+ // /
278+ if c .runeAt (l .stop .north ()) == '_' {
279+ diagUpLines [i ].needsTinyNudgingRight = true
280+ }
281+
282+ // _
283+ // /
284+ if ! l .lonely && c .runeAt (l .stop .nEast ()) == '_' {
285+ diagUpLines [i ].needsTinyNudgingRight = true
286+ }
287+
288+ // _/
289+ if ! l .lonely && c .runeAt (l .start .west ()) == '_' {
290+ diagUpLines [i ].needsTinyNudgingLeft = true
291+ }
292+
293+ // \
294+ // /
295+ if ! l .lonely && c .runeAt (l .stop .north ()) == '\\' {
296+ diagUpLines [i ].needsTinyNudgingRight = true
297+ }
298+
299+ // /
300+ // \
301+ if ! l .lonely && c .runeAt (l .start .south ()) == '\\' {
302+ diagUpLines [i ].needsTinyNudgingLeft = true
303+ }
304+ }
268305
269306 diagDownLines := c .getLinesForSegment ('\\' )
307+ for i , l := range diagDownLines {
308+ // _\
309+ if c .runeAt (l .stop .west ()) == '_' {
310+ diagDownLines [i ].needsTinyNudgingRight = true
311+ }
270312
271- horizontalMidlines := c .getLinesForSegment ('-' )
313+ // _
314+ // \
315+ if c .runeAt (l .start .north ()) == '_' {
316+ diagDownLines [i ].needsTinyNudgingLeft = true
317+ }
318+
319+ // _
320+ // \
321+ if ! l .lonely && c .runeAt (l .start .nWest ()) == '_' {
322+ diagDownLines [i ].needsTinyNudgingLeft = true
323+ }
324+
325+ // \_
326+ if ! l .lonely && c .runeAt (l .stop .east ()) == '_' {
327+ diagDownLines [i ].needsTinyNudgingRight = true
328+ }
329+
330+ // \
331+ // /
332+ if ! l .lonely && c .runeAt (l .stop .south ()) == '/' {
333+ diagDownLines [i ].needsTinyNudgingRight = true
334+ }
335+
336+ // /
337+ // \
338+ if ! l .lonely && c .runeAt (l .start .north ()) == '/' {
339+ diagDownLines [i ].needsTinyNudgingLeft = true
340+ }
341+ }
272342
273343 horizontalBaselines := c .getLinesForSegment ('_' )
274344 for i , l := range horizontalBaselines {
@@ -298,6 +368,30 @@ func (c *Canvas) Lines() []Line {
298368 if c .runeAt (l .start .west ()) == '\\' || c .runeAt (l .start .sWest ()) == '/' {
299369 horizontalBaselines [i ].needsTinyNudgingLeft = true
300370 }
371+
372+ // _\
373+ if c .runeAt (l .stop .east ()) == '\\' {
374+ horizontalBaselines [i ].needsNudgingRight = true
375+ horizontalBaselines [i ].needsTinyNudgingRight = true
376+ }
377+
378+ //
379+ // /_
380+ if c .runeAt (l .start .west ()) == '/' {
381+ horizontalBaselines [i ].needsNudgingLeft = true
382+ horizontalBaselines [i ].needsTinyNudgingLeft = true
383+ }
384+ // _
385+ // /
386+ if c .runeAt (l .stop .south ()) == '/' {
387+ horizontalBaselines [i ].needsTinyNudgingRight = true
388+ }
389+
390+ // _
391+ // \
392+ if c .runeAt (l .start .south ()) == '\\' {
393+ horizontalBaselines [i ].needsTinyNudgingLeft = true
394+ }
301395 }
302396
303397 verticalLines := c .getLinesForSegment ('|' )
@@ -578,35 +672,38 @@ func (c *Canvas) isRoundedCorner(i Index) Orientation {
578672 upperLeft := i .nWest ()
579673 upperRight := i .nEast ()
580674
675+ opensUp := r == '\'' || r == '+'
676+ opensDown := r == '.' || r == '+'
677+
581678 dashRight := c .runeAt (right ) == '-' || c .runeAt (right ) == '+' || c .runeAt (right ) == '_' || c .runeAt (upperRight ) == '_'
582679 dashLeft := c .runeAt (left ) == '-' || c .runeAt (left ) == '+' || c .runeAt (left ) == '_' || c .runeAt (upperLeft ) == '_'
583680
584681 isVerticalSegment := func (i Index ) bool {
585682 r := c .runeAt (i )
586- return r == '|' || r == '+' || r == ')' || r == '('
683+ return r == '|' || r == '+' || r == ')' || r == '(' || isDot ( r )
587684 }
588685
589686 // .- or .-
590687 // | +
591- if dashRight && isVerticalSegment (lowerLeft ) {
688+ if opensDown && dashRight && isVerticalSegment (lowerLeft ) {
592689 return NW
593690 }
594691
595- // -. or -. or -. or _.
596- // | + ) )
597- if dashLeft && isVerticalSegment (lowerRight ) {
692+ // -. or -. or -. or _. or -.
693+ // | + ) ) o
694+ if opensDown && dashLeft && isVerticalSegment (lowerRight ) {
598695 return NE
599696 }
600697
601698 // | or + or | or + or + or_ )
602699 // -' -' +' +' ++ '
603- if dashLeft && isVerticalSegment (upperRight ) {
700+ if opensUp && dashLeft && isVerticalSegment (upperRight ) {
604701 return SE
605702 }
606703
607704 // | or +
608705 // '- '-
609- if dashRight && isVerticalSegment (upperLeft ) {
706+ if opensUp && dashRight && isVerticalSegment (upperLeft ) {
610707 return SW
611708 }
612709
0 commit comments