modern.out: if there are non-whitespace characters, perhaps after editing, turn them into whitespace.

fixs a bug like this when trying to rename CONSTANT:

CONSTANT: a 1 ;
CONSTANT: b 1 ;
->
CONSTANT: a 1 ;
CONSTANT: b 1
locals-and-roots
Doug Coleman 2016-06-20 17:33:54 -07:00
parent 8b90c1a729
commit 20e1a1590c
1 changed files with 6 additions and 2 deletions

View File

@ -4,13 +4,17 @@ USING: accessors combinators combinators.short-circuit
combinators.smart continuations fry io io.encodings.utf8
io.files io.streams.string kernel modern modern.paths
modern.slices multiline namespaces prettyprint sequences sets
splitting strings arrays ;
splitting strings arrays unicode ;
IN: modern.out
symbol: last-slice
: replace-whitespace ( string -- string' )
[ dup blank? [ drop char: \s ] unless ] map ;
: write-whitespace ( obj -- )
[ last-slice get [ swap slice-between ] [ slice-before ] if* io:write ]
! [ last-slice get [ swap slice-between ] [ slice-before ] if* io:write ]
[ last-slice get [ swap slice-between replace-whitespace io:write ] [ drop ] if* ]
[ last-slice namespaces:set ] bi ;
defer: write-literal