[meld] Assume same file type if not available for all files (closes bgo#658407)
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Assume same file type if not available for all files (closes bgo#658407)
- Date: Mon, 17 Oct 2011 11:29:46 +0000 (UTC)
commit 57c8bfa38b53522c5897f47356ded18ab45ee548
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sat Sep 17 13:26:51 2011 +1000
Assume same file type if not available for all files (closes bgo#658407)
For the purpose of syntax highlighting, we always try to determine the
mime type of files, currently using only the filename. In situations
where the filename tells us nothing, we can reasonably assume that all
files have the same type.
This commit changes our behaviour so that, if we get one useful file
type, we use it to fill in missing file types in the remaining files.
This should specifically help with cases where temporary files are
given different extensions. e.g., TortoiseSVN uses .mine, .working, etc.
meld/filediff.py | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index b3413f6..42b715e 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -1093,11 +1093,21 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
self.update_highlighting()
self._connect_buffer_handlers()
self._set_merge_action_sensitivity()
+
+ langs = []
for i in range(self.num_panes):
filename = self.bufferdata[i].filename
if filename:
- lang = srcviewer.get_language_from_file(filename)
- srcviewer.set_language(self.textbuffer[i], lang)
+ langs.append(srcviewer.get_language_from_file(filename))
+
+ # If we have only one identified language then we assume that all of
+ # the files are actually of that type.
+ real_langs = [l for l in langs if l]
+ if real_langs and real_langs.count(real_langs[0]) == len(real_langs):
+ langs = (real_langs[0],) * len(langs)
+
+ for i in range(self.num_panes):
+ srcviewer.set_language(self.textbuffer[i], langs[i])
srcviewer.set_highlight_syntax(self.textbuffer[i],
self.prefs.use_syntax_highlighting)
yield 0
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]