Commits

abudden committed b6b99a9

Added utility function to check if file is in path

Comments (0)

Files changed (1)

autoload/TagHighlight/Utilities.vim

+" Tag Highlighter:
+"   Author:  A. S. Budden <abudden _at_ gmail _dot_ com>
+" Copyright: Copyright (C) 2013 A. S. Budden
+"            Permission is hereby granted to use and distribute this code,
+"            with or without modifications, provided that this copyright
+"            notice is copied with it. Like anything else that's free,
+"            the TagHighlight plugin is provided *as is* and comes with no
+"            warranty of any kind, either expressed or implied. By using
+"            this plugin, you agree that in no event will the copyright
+"            holder be liable for any damages resulting from the use
+"            of this software.
+
+" ---------------------------------------------------------------------
+try
+	if &cp || v:version < 700 || (exists('g:loaded_TagHLUtilities') && (g:plugin_development_mode != 1))
+		throw "Already loaded"
+	endif
+catch
+	finish
+endtry
+let g:loaded_TagHLUtilities = 1
+
+function! TagHighlight#Utilities#FileIsIn(file, root)
+	" Change to use forward slash paths
+	let full_path = substitute(fnamemodify(a:file, ':p'), '\\', '/', 'g')
+	let full_root = substitute(fnamemodify(a:root, ':p'), '\\', '/', 'g')
+
+	" Win32 isn't case sensitive, so make lower case
+	if has("win32")
+		let full_path = tolower(full_path)
+		let full_root = tolower(full_root)
+	endif
+
+	" Make sure root description doesn't end in / (unless it is the root
+	" folder)
+	while full_root =~ './$'
+		let full_root = full_root[:-2]
+	endwhile
+
+	" Compare
+	if full_root == full_path[:len(full_root)-1]
+		return 1
+	else
+		return 0
+	endif
+endfunction
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.