microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.77k stars 28.73k forks source link

use .gitignore to ignore search inside files and folders #78

Closed luisrudge closed 7 years ago

luisrudge commented 8 years ago

use .gitignore to know which files and folders not to search into (think node_modules or packages)

Tyriar commented 8 years ago

I don't think .gitignore should dictate this, in other text editors it's normally done on a project setting or editor setting-level.

luisrudge commented 8 years ago

atom does this. there's no need for project settings or editor settings. If I'm git-ignoring it, there's no need to make this searchable or "autocompletable" (I just invented that word)

Tyriar commented 8 years ago

Huh it does too, I guess I'm thinking of sublime.

ZombieProtectionAgency commented 8 years ago

This is a feature request, not a bug report/issue. Feature suggestions already have a place over at vscodes uservoice.

luisrudge commented 8 years ago

Ops! Sorry. I didn't know there was a uservoice.

image

egamma commented 8 years ago

@luisrudge reopening. We haven't fully figured out what to discuss on user voice and what to discuss in a feature request issue.

This feature request is better discussed here. In particular since the last comment in user voice is not correct :disappointed: .

I could imagine a meta property 'USE_GITIGNORE' and that would be a great opportunity for a pull request:

    "files.exclude": {
        "USE_GITIGNORE": true
    },

@bpasero fyi.

zwacky commented 8 years ago

+1

luisrudge commented 8 years ago

I'm not sure I like the idea of having this as a opt-in flag.. This really should be the default behavior, since searching inside node_modules is not a good thing and certainly isn't the most common use case. Maybe we can add a flag to opt-out this behavior?

Also, I'd like to do this! Can you help me understand which parts of vscode would have to change? THanks!

bpasero commented 8 years ago

I think in the example above it should really be search.exlude and not files.exclude because the former will exclude it from search but the latter from everywhere in the UI including the explorer.

We are reading this setting in from https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/parts/search/common/searchQuery.ts#L18 and I think we could add code there to check for another setting that - if enabled - would mix in anything from .gitignore.

zwacky commented 8 years ago

as @luisrudge already said, this should be the default behaviour like in atom and sublime.

luisrudge commented 8 years ago

@bpasero so.. just add code to read from .gitignore and push that files/folders to searchExcludes ?

bpasero commented 8 years ago

@luisrudge well we also have to convert it to the glob pattern format we use in VS Code. If you look at the default settings and how we ignore the .git folder there you can get an idea of the syntax.

nchammas commented 8 years ago

I agree with @luisrudge that this should be the default behavior, but perhaps there is an intermediate solution we can go for first:

Results from tracked files should come first. Results from git-ignored files should come last.

This is a lower-risk change that, IMO, can be implemented immediately and yield a notable user experience benefit for search.

Currently, results from git-ignored files are mixed in with results from tracked files. This is super noisy, for example, if you're developing in Python and have a virtual environment or build folder within your project folder with all kinds of code that matches almost anything you might search for.

If you're searching for a string across your project, I wager in 100% of cases you want results from your tracked files first, perhaps followed by results from untracked but not ignored files.

Would it make sense to implement this behavior first? Basically, just tweaking the order in which in the results are displayed. I don't think we would even need a new setting for that.

nchammas commented 8 years ago

I think the behavior I described should also apply to the behavior of Command + P, when you want to switch to a file and there are multiple possible matches for the user's search term.

bpasero commented 8 years ago

Currently the sorting is based on our scoring algorithm. I do not think it would make sense to change the sorting based on other criteria unless there is a good way to explain this to the user.

zwacky commented 8 years ago

the sorting can stay the same, just ignore the files listed in .gitignore. this is the absolute main thing that keeps me from using code.

nchammas commented 8 years ago

@bpasero - Could you elaborate? I think the change I'm describing is very easy to explain.

Here's take 2 at explaining the change, simplifying what I said earlier:

Search results are divided into 2 sections--tracked files and everything else. Results within each section are sorted according to the current scoring algorithm. The tracked files section always shows up first.

In addition to being easy to explain, this is the behavior I wager most people would expect.

As I commented earlier, Python projects generally have venv, dist, and build subfolders which contain many Python files, some of which are even copies of the main project files from the last packaging build. These are not part of the project and you don't check these files in because they are copied from third-parties or auto-generated.

Treating these files as equal to the main project files severely detracts from the usability of search. No one wants to see results from these files at the top, if even at all.

I'm sure other languages have similar problems as well.

If ignoring these files in search results is too big of a step to take, then I think the tweak I'm describing here yields the same usability benefit while being straightforward to explain.

bpasero commented 8 years ago

@nchammas I do think that the right fix is to just exclude those files when .gitignore is present and the setting to respect it. otherwise one could also argue why we are not doing the same sorting trick for the search/files exclude setting.

The real work here is to translate .gitignore patterns into our ignore patterns and making sure the solution scales. I have seen .gitignore files with 1000+ rules that would need to be applied many times over many paths.

Tyriar commented 8 years ago

Adding my :+1:. This would solve one of the issues I encountered in the ember-cli test tour, saving devs from setting up a vscode-specific config file. Related PR: https://github.com/ember-cli/ember-cli/pull/5643

asotog commented 8 years ago

Would be nice to not show git ignored files in the project explorer :)

asotog commented 8 years ago

@bpasero tried fixing this as this https://github.com/asotog/vscode/commit/d3cac5b26e57521dc39f8390e3cdf76c1f917342 so from settings default to

      "files.exclude": {
        "**/.git": true,
        "**/.DS_Store": true,
        "VCS": true
    },
mquandalle commented 8 years ago

I think Atom behavior is a reasonable default configuration. .gitignored files and directories are still accessible from the sidebar explorer, but greyed out in the UI and not findable with project-level search.

About parsing, there are libraries like https://www.npmjs.com/package/gitignore-parser but I don’t know if their implementation is completely correct.

hashhar commented 8 years ago

I would like to start working on it. I'll read through the relevant code and try sending a PR within a week or two.

jonatassaraiva commented 8 years ago

+1

hashhar commented 8 years ago

I think this I'll leave this one to someone more capable than me. The size of the project is kind of overwhelming for me and this doesn't look like a monkey-patching issue. :pensive:

danderson00 commented 8 years ago

Estimates on completion of this? It's the only thing I still need atom installed on my PC for.

asotog commented 7 years ago

is someone working on this ? i would like to help on this one :P @bpasero, played on this https://github.com/Microsoft/vscode/pull/4871 worked somehow but not best approach, this is a nice feature to have, today we as developers rely a lot of on transpilers, so you dont want to see the generated files in your dev editor

bpasero commented 7 years ago

It is not being worked on currently. My main concern is how to make a large .gitignore list performant enough against our glob exclude matching.

Tyriar commented 7 years ago

@bpasero can you define large? Here are some common examples https://github.com/github/gitignore

bpasero commented 7 years ago

@Tyriar yup (https://chromium.googlesource.com/chromium/src.git/+/master/.gitignore):

*.gypcmd
*.mk
*.ncb
*.opensdf
*.orig
*.pdb
*.props
*.pyc
*.pyproj
*.rules
*.sdf
*.sln
*.sublime-project
*.sublime-workspace
*.suo
*.targets
*.user
*.vc.opendb
*.vcproj
*.vcxproj
*.vcxproj.filters
*.vpj
*.vpw
*.vpwhistu
*.vtg
*.xcodeproj
*.xcworkspace
*.VC.db
*_proto.xml
*_proto_cpp.xml
*~
!Android.mk
.*.sw?
.DS_Store
.classpath
.cproject
.gdb_history
.gdbinit
.landmines
.metadata
.project
.pydevproject
.checkstyle
cscope.*
GPATH
GRTAGS
GSYMS
GTAGS
Session.vim
tags
Thumbs.db
v8.log
vs-chromium-project.txt
# Settings directories for eclipse
/.externalToolBuilders/
/.settings/
/.vs/
# Visual Studio Code
/.vscode/
/_out
/android_emulator_sdk
/ash/ash_unittests_run.xml
/base/base_unittests_run.xml
/breakpad/src/
/build/android/bin
/build/Debug
/build/Debug_x64
/build/goma
/build/gomacc.lock
/build/ipch/
/build/Release
/build/Release_x64
/build/win_toolchain.json
/build/util/LASTCHANGE*
/build/util/support
/build/x64/
/build/linux/bin/eu-strip
/build/linux/debian_*-sysroot/
/build/linux/ubuntu_*-sysroot/
/build/mac_files
/buildtools
# The Chrome OS build creates a /c symlink due to http://crbug.com/54866.
/c
/cdm
/ceee/internal/
/chrome/angle_unittests_run.xml
/chrome/content_gl_tests_run.xml
/chrome/gl_tests_run.xml
/chrome/gles2_conform_test_run.xml
/chrome/tab_capture_performance_tests_run.xml
/chrome/telemetry_gpu_test_run.xml
/chrome/app/theme/default_100_percent/google_chrome
/chrome/app/theme/default_200_percent/google_chrome
/chrome/app/theme/google_chrome
/chrome/browser/autofill/internal
/chrome/browser/chromeos/login/screenshot_testing/golden_screenshots/*.png
/chrome/browser/chromeos/login/screenshot_testing/artifacts
/chrome/browser/extensions/api/ledger/
/chrome/browser/extensions/default_extensions/chromeos
/chrome/browser/google/linkdoctor_internal
/chrome/browser/internal
/chrome/browser/performance_monitor/performance_monitor.xml
/chrome/browser/protector/internal
/chrome/browser/resources/chromeos/quickoffice
/chrome/browser/resources/pdf/html_office
/chrome/browser/resources/media_router_internal/
/chrome/browser/resources/settings_internal/
/chrome/browser/resources/software_rendering_list
/chrome/browser/spellchecker/internal
/chrome/browser_tests_run.xml
/chrome/chrome_run.xml
/chrome/chrome_user32_delay_imports.xml
/chrome/chrome_version_resources.xml
/chrome/common/extensions/api/api.xml
/chrome/common/extensions/api/ledger/
/chrome/Hammer
/chrome/installer/linux/internal
/chrome/installer/mac/internal
/chrome/installer/mac/third_party/xz/xz
/chrome/installer/mini_installer.xml
/chrome/installer/mini_installer/mini_installer.aps
/chrome/installer/mini_installer/support
/chrome/installer/mini_installer_syzygy.xml
/chrome/installer/mini_installer_tests_run.xml
/chrome/installer_util_strings.xml
/chrome/interactive_ui_tests_run.xml
/chrome/setup.xml
/chrome/setup_unittests.xml
/chrome/supplement.gypi
/chrome/sync_integration_tests_run.xml
/chrome/test/android/telemetry_tests/browser_tests/*.wpr
/chrome/test/chromeos/autotest/files/client/deps/chrome_test/test_src/
/chrome/test/chromeos/autotest/files/client/deps/page_cycler_dep/test_src/
/chrome/test/chromeos/autotest/files/client/deps/perf_data_dep/test_src/
/chrome/test/chromeos/autotest/files/client/deps/pyauto_dep/test_src/
/chrome/test/chromeos/autotest/files/client/deps/telemetry_dep/test_src/
/chrome/test/data/extensions/api_test/permissions/nacl_enabled/bin
/chrome/test/data/firefox2_profile/searchplugins
/chrome/test/data/firefox2_searchplugins
/chrome/test/data/firefox3_profile/searchplugins
/chrome/test/data/firefox3_searchplugins
/chrome/test/data/gpu/vectortown_endurance/
/chrome/test/data/gpu/vt/
/chrome/test/data/layout_tests
/chrome/test/data/osdd
/chrome/test/data/pdf_private
/chrome/test/data/perf/canvas_bench
/chrome/test/data/perf/frame_rate/content
/chrome/test/data/perf/frame_rate/private
/chrome/test/data/perf/private/
/chrome/test/data/perf/third_party/
/chrome/test/data/plugin/
/chrome/test/data/webrtc/resources
/chrome/test/media_router/internal
/chrome/tools/memory
/chrome/tools/test/reference_build
/chrome/unit_tests_run.xml
/chrome/web_ui_mojo_bindings.xml
/chrome_elf/chrome_elf_resources.xml
/chromecast/internal
/clank
/cloud_print/cloud_print_version_resources.xml
/components/chrome_settings_proto_generated_compile.xml
/components/cloud_policy_proto_generated_compile.xml
/components/gcm_driver.xml
/components/leveldb_proto_test_support.xml
/components/rappor.xml
/components/resources/default_100_percent/google_chrome
/components/resources/default_200_percent/google_chrome
/components/search_engines/prepopulated_engines.xml
/components/suggestions.xml
/components/variations.xml
/content/browser/service_worker/proto.xml
/content/content_browsertests_run.xml
/content/content_common_mojo_bindings.xml
/content/content_unittests_run.xml
/content/test/data/gpu/generated/
/content/test/data/gpu/gpu_reference/
/content/test/data/layout_tests/
/content/test/data/plugin/
/content/web_ui_test_mojo_bindings.xml
/data
/delegate_execute
/device/serial/device_serial_mojo.xml
/google_apis/gcm/gcm.xml
/google_apis/internal
/googleurl
/gpu/gles2_conform_test
/infra/.recipe_deps
/internal_gyp
/ios/third_party/earl_grey/src
/ios/third_party/fishhook/src
/ios/third_party/gcdwebserver/src
/ios/third_party/material_text_accessibility_ios/src
/ios/third_party/ochamcrest/src
/ios_internal
/llvm
/media/cast/logging/cast_logging_proto_lib.xml
/media/cdm/api
/media/media_asm.xml
/media/media_mojo_bindings.xml
/media/test/data/internal
/media/yuv_convert_simd_x86.xml
/metro_driver
/mojo/hello_world_service.xml
/mojo/mojo_application_bindings.xml
/mojo/mojo_application_manager_unittests.xml
/mojo/mojo_apps_js_bindings.xml
/mojo/mojo_apps_js_unittests_run.xml
/mojo/mojo_clipboard_bindings.xml
/mojo/mojo_content_handler_bindings.xml
/mojo/mojo_core_window_manager_bindings.xml
/mojo/mojo_echo_service_bindings.xml
/mojo/mojo_example_service_bindings.xml
/mojo/mojo_external_service_bindings.xml
/mojo/mojo_geometry_bindings.xml
/mojo/mojo_gles2_bindings.xml
/mojo/mojo_gpu_bindings.xml
/mojo/mojo_input_events_bindings.xml
/mojo/mojo_js_unittests_run.xml
/mojo/mojo_keyboard_bindings.xml
/mojo/mojo_launcher_bindings.xml
/mojo/mojo_media_viewer_bindings.xml
/mojo/mojo_native_viewport_bindings.xml
/mojo/mojo_navigation_bindings.xml
/mojo/mojo_network_bindings.xml
/mojo/mojo_public_bindings_unittests.xml
/mojo/mojo_public_test_interfaces.xml
/mojo/mojo_public_unittests.xml
/mojo/mojo_sample_service.xml
/mojo/mojo_shell_bindings.xml
/mojo/mojo_shell_lib.xml
/mojo/mojo_spy.xml
/mojo/mojo_surface_id_bindings.xml
/mojo/mojo_surfaces_app_bindings.xml
/mojo/mojo_surfaces_bindings.xml
/mojo/mojo_test_service_bindings.xml
/mojo/mojo_view_manager_bindings.xml
/mojo/mojo_window_manager_bindings.xml
/mojo/mojo_wm_flow_embeddee_bindings.xml
/mojo/mojo_wm_flow_embedder_bindings.xml
/mojo/mojom_test.xml
/mojo/sample_service.xml
/native_client
/net/Debug
/net/net_derived_sources.xml
/net/net_unittests_run.xml
/net/Release
/net/testserver.log
/out*
/ppapi/native_client/nacl_irt.xml
/ppapi/native_client/ppapi_lib.xml
/remoting/android/internal/
/remoting/appengine/
/remoting/host/installer/linux/internal/
/remoting/ios/
/remoting/internal/
/remoting/proto/chromotocol_proto_lib.xml
/remoting/remoting_core_resources.xml
/remoting/remoting_elevated_controller.xml
/remoting/remoting_host.xml
/remoting/remoting_host_event_logger.xml
/remoting/remoting_host_installation.xml
/remoting/remoting_host_messages.xml
/remoting/remoting_infoplist_strings.xml
/remoting/remoting_lib_idl.xml
/remoting/remoting_lib_rc.xml
/remoting/remoting_me2me_host.xml
/remoting/remoting_native_messaging_manifests.xml
/remoting/remoting_version_resources.xml
/remoting/remoting_windows_resources.xml
/remoting/test/internal/
/remoting/tools/internal/
/remoting/webapp/app_remoting/internal/
/sandbox/linux/seccomp-legacy/
/sdch/open-vcdiff
/seccompsandbox
/signing_keys
/skia/tools/clusterfuzz-data/
/sql/sql_unittests_run.xml
/sync/sync.xml
/sync_testserver.log
/testing/gmock
/testing/gtest
/testserver.log
/tools/luci-go/linux64/isolate
/tools/luci-go/mac64/isolate
/tools/luci-go/win64/isolate.exe
/third_party/__START__
/third_party/accessibility-developer-tools/
/third_party/accessibility_test_framework/lib/*.jar
/third_party/adobe/flash/binaries
/third_party/adobe/flash/symbols
/third_party/amd/
/third_party/android_protobuf/src
/third_party/android_support_test_runner/lib/*.aar
/third_party/android_support_test_runner/lib/*.jar
/third_party/android_tools/
/third_party/android_tools_internal/
/third_party/android_webview_glue/src
/third_party/angle
/third_party/angle_dx11
/third_party/apache-mime4j
/third_party/apache-portable-runtime/src
/third_party/apache_velocity/lib/*.jar
/third_party/apache-win32/bin/*.exe
/third_party/apache-win32/bin/*.dll
/third_party/apache-win32/bin/iconv/*.so
/third_party/apache-win32/modules/*.so
/third_party/apache-win32/modules/*.dll
/third_party/asan
/third_party/bidichecker
/third_party/bison
/third_party/boringssl/src
/third_party/bouncycastle/lib/*.jar
/third_party/byte_buddy/lib/*.jar
/third_party/cacheinvalidation/cacheinvalidation_unittests_run.xml
/third_party/cardboard-java/src
/third_party/catapult
/third_party/ced/src
/third_party/chromeos_login_manager
/third_party/chromeos_text_input
/third_party/chromite
/third_party/cld_2/src
/third_party/cld_3/src
/third_party/colorama/src
/third_party/cros
/third_party/cros_system_api
/third_party/custom_tabs_client/src
/third_party/cygwin
/third_party/deqp/src
/third_party/directxsdk
/third_party/dom_distiller_js/dist
/third_party/drmemory/drmemory-windows-sfx.exe
/third_party/drmemory/unpacked
/third_party/elfutils/src
/third_party/errorprone/lib
/third_party/espresso/lib/*.jar
/third_party/eyesfree/src
/third_party/ffmpeg
/third_party/findbugs
/third_party/flac
/third_party/flatbuffers/src
/third_party/fontconfig/src
/third_party/freetype-android/src
/third_party/freetype2/src
/third_party/gles2_conform
/third_party/glslang/src
/third_party/gnu_binutils/
/third_party/google_appengine_cloudstorage
/third_party/google_toolbox_for_mac/src
/third_party/googlemac
/third_party/gvr-android-sdk/src
/third_party/gperf
/third_party/grpc
/third_party/guava/lib/*.jar
/third_party/hamcrest/lib/*.jar
/third_party/httpcomponents-client
/third_party/httpcomponents-core
/third_party/hunspell_dictionaries
/third_party/icu
/third_party/icu4j/lib/*.jar
/third_party/intellij/lib/*.jar
/third_party/jarjar
/third_party/javax_inject/lib/*.jar
/third_party/jsoncpp/source
/third_party/jsr-305/src
/third_party/junit/src
/third_party/kasko
/third_party/khronos_glcts
/third_party/leakcanary/src
/third_party/leveldatabase/src
/third_party/leveldb
/third_party/libc++-static/libc++.a
/third_party/libaddressinput/src
/third_party/libexif/sources
/third_party/libFuzzer/src
/third_party/libjingle/source
/third_party/libjpeg_turbo
/third_party/liblouis/src
/third_party/libphonenumber/dist
/third_party/libsrtp
/third_party/libupnp
/third_party/libvpx/source/libvpx
/third_party/libwebm/source
/third_party/libyuv
/third_party/lighttpd
/third_party/llvm
/third_party/llvm-allocated-type
/third_party/llvm-bootstrap
/third_party/llvm-build
/third_party/lss
/third_party/mesa/src
/third_party/mingw-w64
/third_party/minigbm/src
/third_party/mkl
/third_party/mocha
/third_party/mockito/src
/third_party/nacl_sdk_binaries/
/third_party/netty-tcnative/src
/third_party/netty4/src
/third_party/nss
/third_party/objenesis/lib/*.jar
/third_party/omaha/src/omaha
/third_party/openmax_dl/
/third_party/openh264/src
/third_party/ow2_asm/lib/*.jar
/third_party/pdfsqueeze
/third_party/pdfium
/third_party/pefile
/third_party/perl
/third_party/platformsdk_win7
/third_party/platformsdk_win8
/third_party/ppapi
/third_party/psyco_win32
/third_party/pthreads-win32
/third_party/py_trace_event/src
/third_party/pyelftools
/third_party/pyftpdlib/src
/third_party/pylib
/third_party/pymox/src
/third_party/python_24
/third_party/python_26
/third_party/pywebsocket/src
/third_party/pywebsocket/src
/third_party/re2/src
/third_party/requests/src
/third_party/robolectric/lib/*.jar
/third_party/robolectric/robolectric
/third_party/scons-2.0.1
/third_party/sfntly/src
/third_party/shaderc/src
/third_party/skia
/third_party/smhasher/src
/third_party/snappy/src
/third_party/SPIRV-Tools/src
/third_party/sqlite4java/lib/**/*.dll
/third_party/sqlite4java/lib/**/*.jar
/third_party/sqlite4java/lib/**/*.jnilib
/third_party/sqlite4java/lib/**/*.so
/third_party/swiftshader/
/third_party/syzygy
/third_party/syzygy/binaries
/third_party/tsan/
/third_party/ub-uiautomator/lib
/third_party/usb_ids
/third_party/usrsctp/usrsctplib
/third_party/v8-i18n
/third_party/valgrind
/third_party/v4l2capture
/third_party/visualmetrics
/third_party/wayland/src
/third_party/wayland-protocols/src
/third_party/wds/src
/third_party/webdriver/pylib
/third_party/webdriver/python/selenium
/third_party/webgl
/third_party/webgl/src
/third_party/webpagereplay/
/third_party/webrtc
/third_party/widevine/cdm/chromeos
/third_party/widevine/cdm/linux
/third_party/widevine/cdm/mac
/third_party/widevine/cdm/win
/third_party/widevine/test/license_server
/third_party/win_toolchain/.timestamps
/third_party/win_toolchain/files
/third_party/wix
/third_party/xdg-utils
/third_party/xulrunner-sdk
/third_party/yasm/binaries
/third_party/yasm/generate_files.xml
/third_party/yasm/source/patched-yasm
/third_party/yasm/yasm.xml
/tools/.bisect-builds-cache.json
/tools/distcc
/tools/gn/bin/linux
/tools/gn/bin/mac
/tools/gn/bin/win
/tools/gyp
/tools/histograms
/tools/json_schema_compiler/test/json_schema_compiler_tests.xml
/tools/metrics/actions/actions.old.xml
/tools/metrics/histograms/histograms.before.pretty-print.xml
/tools/page_cycler/acid3
/tools/perf/data
/tools/perf/internal
/tools/perf/results.html
/tools/swarming_client
/tools/tryserver
/tools/win/link_limiter/build
/ui/file_manager/internal
/ui/keyboard/keyboard_mojom_bindings.xml
/ui/surface/surface.xml
/ui/surface/surface_gpu_tests.xml
/v8
/webkit/data
/webpagereplay_logs/
/win8/delegate_execute/delegate_execute_version_resources.xml
/win8/metro_driver/metro_driver_version_resources.xml
/x86-generic_out/
/xcodebuild
octref commented 7 years ago

@bpasero ag respects .gitignore and claims to be very performant. The only problem is it needs some effort to get it to work on Windows.

hashhar commented 7 years ago

ag has broken gitignore support. It doesn't support directory excludes properly. And let's try to keep external dependencies to a minimum.

@bpasero What would happen if all rules from .gitignore were inputted to the exclude glob field found when searching? Apart from speed issues I mean.

bpasero commented 7 years ago

I think it would work apart from an unusable slow search :). I think instead of trying to make the gitignore patterns work with our world we should shell out to git itself and ask it if a certain list of paths are valid paths for tracking changes.

Tyriar commented 7 years ago

/cc @chrmarti

hashhar commented 7 years ago

@bpasero I think git has something like that. Mercurial has a command hg status -i which lists the ignored files present in the work tree and a similar command that shows all the tracked files and directories. Something similar can be achieved for git I think.

EDIT: Yup. git ls-files --ignored --exclude-standard lists all the files explicitly ignored due to the .gitignore file. And ( git status --short| grep '^?' | cut -d\ -f2- && git ls-files ) | sort -u gives all files that aren't ignored. Any git installation will provide grep, cut and sort so I think portability won't be an issue.

samuelt1 commented 7 years ago

would it be possible to write an extension to do this?

bpasero commented 7 years ago

Currently not.

asotog commented 7 years ago

@bpasero i personally think for search is fine to keep it as it is now, results returns from any file (even ignored). But for files explorer (tree view) this is helpful, and won't affect performance, even, might increase it because will not be showing useless files (from dev perspective you dont want to see node_modules, bower files, js maps, transpiled js, some times etc) on that view, here is a library that seems doing that https://github.com/atom/git-utils#repositoryisignoredpath BUT built by the neighbors :(

rjmunro commented 7 years ago

Please make this a switch in the search UI itself, like "regex", "whole word" and "match case", not something hidden away in config!

I usually want it, but the times I don't want it are not rare, and I want to be able to just turn it off and search without changing configs or anything.

For example, I might have files that have been installed by bower that I want to include in a particular search because I'm trying to figure out how a library works, or maybe I want to include log / debug files that my code has written, but are gitignored.

I think that if I try and search inside a folder, which has itself been completely .gitignored, I am signalling my intent to search it anyway - it would be good if the "ignore .gitignored" button could be greyed out in this case.

therealkenc commented 7 years ago

Just tried out Visual Studio 2017 RC with the new “Open Folder” feature. They seem to respect .gitignore out of the box. I was kind of pleasantly surprised. No word on performance (performance is not really Studio's thing anyway.)

fbnlsr commented 7 years ago

It seems people are either rooting for having Code respect .gitignore for search results, or file explorer, or both.

I think the option should be set for both, but we should have to possibility to let the file explorer show .gitignored files while not displaying them in search results, or the other way around.

v3ss0n commented 7 years ago

2017 and Still don't ignore repo ignore files? :stuck_out_tongue:

tito commented 7 years ago

Everytime i want to use vscode for my projects, i face this issue: showing all dot files, cache files, build files, indexed, which are all declared to be ignored in the .gitignore, make the editor unusable:

:(

asotog commented 7 years ago

on every project i have to use the exclude files, via .vscode/settings.json and waste .gitignore functionality :(

bdbch commented 7 years ago

I also would propose to not simply hide files but make them transculent in the sidebar so you can still open files and folders which are ignored BUT you can't search them and you see a visual indicator that it's not watched in your project.

Thats the only missing feature keeping me away from using VS Code on a daily base and keep to stick to Atom.

apmeyer commented 7 years ago

+1 for hiding .gitignore files from the file browser. If it's not the default behavior, at least having the option to hide these files would be ideal. The lack of this feature is keeping me in Atom (and Atom's freeze-ups are driving me nuts).

denieler commented 7 years ago

+1 to implement .gitignore functionality finally

v3ss0n commented 7 years ago

@denieler where did they implement?

bdbch commented 7 years ago

Any new update on this feature? For me it's still the main issue why I don't use vscode over atom.

For me this should handle

I would like to check if I can find some way to implement it but it will take me a bit to get into the project.

denieler commented 7 years ago

@db2k yeah.. I even wanted to jump from Atom to VS code, but when I found this issue now I'm not sure..