[gobject-introspection] giscanner: Print relative filename paths when warning



commit 886d36d65f3bcd30ddc23005e378c0fb4d295e21
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Thu Nov 8 18:26:29 2018 +0100

    giscanner: Print relative filename paths when warning
    
    g-ir-scanner would cut away the 'common prefix' between the current
    working directory and the file about be warned about. This is
    problematic when using automatic jumping to warnings and errors, as it'd
    mean the editor can't find the relevant file.
    
    For example, if g-ir-scanner is run from 'build/', and a warning occurs
    on a file in 'src/file.c', the scanner would print the warning
    'src/file.c:123: Warning: This and that'. Running this from e.g. meson
    would mean e.g. VIM would not find the correct file to jump to.
    
    Meanwhile, GCC, in the same setup, would print '../src/file.c:123:
    Warning: ...', as that is the relative path from where the scanner is
    ran, and e.g. VIM would behave in a correct way.

 giscanner/message.py | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
---
diff --git a/giscanner/message.py b/giscanner/message.py
index 02377896..f20578f3 100644
--- a/giscanner/message.py
+++ b/giscanner/message.py
@@ -80,11 +80,8 @@ class Position(object):
                                         self.column or -1)
 
     def format(self, cwd):
-        filename = os.path.realpath(self.filename)
-        cwd = os.path.realpath(cwd)
-        common_prefix = os.path.commonprefix((filename, cwd))
-        if common_prefix:
-            filename = os.path.relpath(filename, common_prefix)
+        filename = os.path.relpath(os.path.realpath(self.filename),
+                                   os.path.realpath(cwd))
 
         if self.column is not None:
             return '%s:%d:%d' % (filename, self.line, self.column)


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