ada-mode-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Mixed EOL characters causes improper font locking and often wisi parser


From: brownt . fully
Subject: Mixed EOL characters causes improper font locking and often wisi parser hangs
Date: Sun, 16 May 2021 23:42:36 -0000

I've encountered situations where there are multiple developers and
sometimes (likely due to merging), we will end up with source files
that contain both CRLF and LF line endings on different lines of the
source file.  Ideally, these should be cleaned up and only a single
line ending should be used for a file, however it is a reality which
likely will not be immediately solved.  When files with mixed line
endings are encountered in ada-mode, I've seen a couple different
problems.  The least severe is that the font locking ends up being
skewed and certain characters are colored in the wrong font.  In the
worst case scenario, it appears the back-end wisi parser hangs and is
not able to successfully process the source file, leaving the entire
file without any font locking.

This has become problematic enough that I've actually created my own
macro to clean-up these files when I run across them, save the file
and then kill off the wisi parser (via wisi-parse-kill) and restart
ada-mode.

I'm not exactly sure why the parser hangs in certain scenarios and not
in others, but I suspect that it just depends on where the
interleaving of the line endings occurs and how complicated the source
is to parse.

The following simple hello world program can demonstrate the skewed
font locking.  Starting with the source stored in hello_world.adb.  I
am currently using ada-mode 7.1.1 and wisi 3.1.1, but assume that this
can also be demonstrated on the latest version as well.

=============================
with Ada.Text_IO;

procedure Hello_World is
begin
   Ada.Text_IO.Put_Line ("Hello, World!");
end Hello_World;
=============================

We can split the file so half of the file is formatted with CRLF and
the other half only with LF.

unix2dos --newfile hello_world.adb hello_world_dos.adb
dos2unix --newfile hello_world.adb hello_world_unix.adb
head --lines=3 hello_world_dos.adb >hello_world_merged.adb
tail --lines=3 hello_world_unix.adb >>hello_world_merged.adb

At this point, loading hello_world_merged.adb into Emacs with ada-mode
should demonstrate the problem with the font locking being shifted.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]