Extra CRs are now filtered out from the source file for :list.
authorGintautas Miliauskas <gintautas.miliauskas@gmail.com>
Thu, 30 Oct 2014 04:14:17 +0000 (23:14 -0500)
committerAustin Seipp <austin@well-typed.com>
Thu, 30 Oct 2014 04:14:17 +0000 (23:14 -0500)
Fixes #9367.

Reviewers: austin

Reviewed By: austin

Subscribers: #ghc_windows_task_force, thomie, carter, simonmar

Differential Revision: https://phabricator.haskell.org/D382

GHC Trac Issues: #9367

ghc/InteractiveUI.hs
testsuite/tests/ghci/scripts/Makefile
testsuite/tests/ghci/scripts/T9367-raw.stdout [new file with mode: 0644]
testsuite/tests/ghci/scripts/T9367.hs [new file with mode: 0644]
testsuite/tests/ghci/scripts/T9367.script [new file with mode: 0644]
testsuite/tests/ghci/scripts/all.T

index 3192d20..ed4ea7b 100644 (file)
@@ -2934,7 +2934,8 @@ listModuleLine modl line = do
 listAround :: MonadIO m => RealSrcSpan -> Bool -> InputT m ()
 listAround pan do_highlight = do
       contents <- liftIO $ BS.readFile (unpackFS file)
-      let ls  = BS.split '\n' contents
+      -- Drop carriage returns to avoid duplicates, see #9367.
+      let ls  = BS.split '\n' $ BS.filter (/= '\r') contents
           ls' = take (line2 - line1 + 1 + pad_before + pad_after) $
                         drop (line1 - 1 - pad_before) $ ls
           fst_line = max 1 (line1 - pad_before)
index 73f6203..873de43 100644 (file)
@@ -39,3 +39,8 @@ ghci056_setup:
 T6106_prep:
        '$(TEST_HC)' $(TEST_HC_OPTS) -v0 --make T6106_preproc
 
+.PHONY: T9367
+T9367:
+       '$(TEST_HC)' $(TEST_HC_OPTS) --interactive -v0 -ignore-dot-ghci                   < T9367.script > T9367-raw.run.stdout
+       cmp T9367-raw.run.stdout T9367-raw.stdout
+
diff --git a/testsuite/tests/ghci/scripts/T9367-raw.stdout b/testsuite/tests/ghci/scripts/T9367-raw.stdout
new file mode 100644 (file)
index 0000000..69da032
--- /dev/null
@@ -0,0 +1,6 @@
+Breakpoint 0 activated at T9367.hs:1:5-9\r
+"Stopped at T9367.hs:1:5-9\r
+_result :: [Char] = _\r
+1  x = "abc"\r
+       ^^^^^\r
+2  main = print x\r
diff --git a/testsuite/tests/ghci/scripts/T9367.hs b/testsuite/tests/ghci/scripts/T9367.hs
new file mode 100644 (file)
index 0000000..0f24fa4
--- /dev/null
@@ -0,0 +1,2 @@
+x = "abc"\r
+main = print x\r
diff --git a/testsuite/tests/ghci/scripts/T9367.script b/testsuite/tests/ghci/scripts/T9367.script
new file mode 100644 (file)
index 0000000..afc89a8
--- /dev/null
@@ -0,0 +1,4 @@
+:l T9367
+:b 1
+:main
+:list
index ede9807..624f431 100755 (executable)
@@ -43,6 +43,10 @@ test('ghci024',
      when(fast(), skip),
      run_command,
      ['$MAKE -s --no-print-directory ghci024'])
+test('T9367',
+     when(fast() or config.os != 'mingw32', skip),
+     run_command,
+     ['$MAKE -s --no-print-directory T9367'])
 test('ghci025', normal, ghci_script, ['ghci025.script'])
 test('ghci026', normal, ghci_script, ['ghci026.script'])