Пример #1
0
        public void Custom()
        {
            string[] custom = new string[] { "*.foo", "a*b.test", "test.ego", "any*" };
            IgnoredFiles.SetIngnoredFiles(custom);
            string[] ignore = new string[]
            {
                ".foo",
                "file.foo",
                "asdb.test",
                "ab.test",
                "AvB.test",
                "test.ego",
                "anymore",
                "any",
                "any.bar"
            };
            string[] pass = new string[] { "a.foo.bar", "bacb.test", "a.test", "atest.ego", "test.egomotion", "manymore", "many" };

            foreach (var item in ignore)
            {
                Assert.IsTrue(IgnoredFiles.ShouldIgnore(item));
            }

            foreach (var item in pass)
            {
                Assert.IsFalse(IgnoredFiles.ShouldIgnore(item));
            }
        }
Пример #2
0
        void DrawIgnoredFilesAndFolders()
        {
            EditorGUI.indentLevel++;
            EditorGUILayout.LabelField(new GUIContent("Ignored Files and Folders", "File and folders that will be ignored when adding folders to change files"));
            EditorGUI.indentLevel--;
            EditorGUILayout.BeginVertical(_style.IndentedBox());
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(new GUIContent("Default Ignored Files", "These files are always ignored when adding folders"), GUILayout.ExpandWidth(false));
            EditorGUILayout.LabelField(StringUtils.ArrayToString(IgnoredFiles.DefaultList), EditorStyles.wordWrappedLabel);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.LabelField(new GUIContent("Custom Ignored Files", "Add filenames and wildcards entries here to have them ignored when adding folders"), GUILayout.ExpandWidth(false));
            EditorGUI.indentLevel++;
            bool update = false;

            int remove = -1;

            for (int ii = 0; ii < _customIgnoredFiles.Count; ++ii)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUI.BeginChangeCheck();
                _customIgnoredFiles[ii] = EditorGUILayout.TextField(_customIgnoredFiles[ii]);

                if (EditorGUI.EndChangeCheck())
                {
                    update = true;
                }

                EditorGUILayout.Space();

                if (_style.MinusButton("Remove ignored file pattern"))
                {
                    bool removeCheck = true;

                    if (!string.IsNullOrEmpty(_customIgnoredFiles[ii].Trim()))
                    {
                        removeCheck = EditorUtility.DisplayDialog("Remove ignored file pattern?", "Are you sure you want to remove \"" + _customIgnoredFiles[ii] + "\" from the ignore list?", "Remove", "Cancel");
                    }

                    if (removeCheck)
                    {
                        remove = ii;
                    }
                }

                EditorGUILayout.EndHorizontal();
                GUILayout.Space(2);
            }

            if (remove > -1)
            {
                IgnoredFiles.Remove(_customIgnoredFiles[remove]);
                _customIgnoredFiles.RemoveAt(remove);
                _settings.SetDirty();
                _settings.Save();
            }

            if (update)
            {
                IgnoredFiles.SetIngnoredFiles(_customIgnoredFiles.ToArray());
                _settings.SetDirty();
                _settings.Save();
                update = false;
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.Space();

            if (_style.PlusButton("Add new ignored file pattern"))
            {
                _customIgnoredFiles.Add("");
            }

            EditorGUILayout.EndHorizontal();
            EditorGUI.indentLevel--;
            GUILayout.Space(4);
            EditorGUILayout.EndVertical();
        }