microsoft / VS-Macros

An extension for Visual Studio 2013+ that enables the use of macros in the IDE. The extension can record most of the features in Visual Studio including text editing operations.
Other
131 stars 41 forks source link

vsFindOptions is undefined #37

Open CGB0 opened 7 years ago

CGB0 commented 7 years ago
/// <reference path="C:\Users\<user>\AppData\Local\Microsoft\VisualStudio\14.0\Macros\dte.js" />

debugger;
dte.SuppressUI = true
var objSelection  = dte.ActiveDocument.Selection
objSelection.StartOfDocument()
While(objSelection.FindText("#region",   vsFindOptions.vsFindOptionsMatchInHiddenText))
   alert ( " found something")
Loop
objSelection.StartOfDocument()
dte.SuppressUI = false

This code gives the error vsFindOptions is undefined. How do we match lines?

My goal here is to run though the active document and collapse any line that has the text "#region" or "function" in the line

Any help appreciated.

Thanks Colin

daiplusplus commented 1 year ago

vsFindOptions is an enum - there's no equivalent in JScript 3 so you'll need to use named values:

var vsFindOptions_MatchInHiddenText = 512; // https://learn.microsoft.com/en-us/dotnet/api/envdte.vsfindoptions?view=visualstudiosdk-2022

do {
    var findResult = objSelection.FindText("#region", vsFindOptions_MatchInHiddenText  );
    if( findResult.Etc ) break;
}
while( true );

// etc

Also, your code as-posted is won't work: