[go: nahoru, domu]

Skip to content

Commit

Permalink
Fix record rendering bug
Browse files Browse the repository at this point in the history
In an attempt to avoid spaces in code that was rendered with a hover,
newlines where accidentally swallowed because String.trim also removes
newlines.
  • Loading branch information
hojberg committed Aug 30, 2024
1 parent a1c72f0 commit 63a7f83
Show file tree
Hide file tree
Showing 4 changed files with 2,281 additions and 11 deletions.
31 changes: 23 additions & 8 deletions src/Code/Syntax/SyntaxSegment.elm
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,29 @@ view syntaxConfig ((SyntaxSegment sType sText) as segment) =
-- hover background, so it gets separate to another dom node.
-- This results in cleaner looking hovers and tooltip
-- positionings
if String.startsWith " " sText && String.endsWith " " sText then
span [] [ text " ", view_ (text (String.trim sText)), text " " ]

else if String.startsWith " " sText then
span [] [ text " ", view_ (text (String.trim sText)) ]

else
span [] [ view_ (text (String.trim sText)), text " " ]
let
f c ( start, middle, end ) =
let
s =
String.fromChar c
in
if c == ' ' || c == '\n' then
if String.isEmpty middle then
( start ++ s, middle, end )

else
( start, middle, end ++ s )

else
( start, middle ++ s, end )

viewText ( start, middle, end ) =
span [] [ text start, view_ (text middle), text end ]
in
sText
|> String.toList
|> List.foldl f ( "", "", "" )
|> viewText

else
view_ (text sText)
Expand Down
1 change: 1 addition & 0 deletions src/Lib/Util.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Lib.Util exposing (..)

import Http
import Json.Decode as Decode
import List.Extra as ListE
import List.Nonempty as NEL
import Process
import Task
Expand Down
Loading

0 comments on commit 63a7f83

Please sign in to comment.