views:

23

answers:

1

I'm creating a custom Visual Studio editor and am currently trying to enable find and replace.

In the IVsFindTarget.Find method it says to return __VSFINDRESULT.Found and I'm assuming __VSFINDRESULT.AndReplace flags when a find and replace request it called. The issue is that AndReplace is defined:

VSFR_AndReplace = -2147483648

But the documentation says:

Returned in combination with Found or NotFound

VSFR_AndReplace is not a valid uint. How could I return a combination of the two?

+1  A: 

Try just using VSFR_Replaced (which says it is already a combination of Found and Replaced), for brevity.

As for being a valid uint, you can certainly treat it like a valid uint. Even though the decimal representation is signed, consider the underlying representation. In binary, it's 0b 11111111 11111111 10000000 00000000, or 0xffffffff80000000 in hex. You can just ignore the upper two words, making it 0x8000000. Anyways, since these are used as flags, you can pretty safely just ignore the actual value anyways, and do something like:

(uint)(__VSFINDRESULT.VSFR_Found | __VSFINDRESULT.VSFR_AndReplace)
Noah Richards
(uint)(__VSFINDRESULT.VSFR_AndReplace | __VSFINDRESULT.VSFR_Found); returns "Overflow in constant value computation". I tried 0x8000000 but it didn't seem to work either. :\
Adam Driscoll
Can you file a bug on [Connect](http://connect.microsoft.com/VisualStudio)? We may both be misreading it, but it seems logical to assume that you can put those together (and cast to a uint, assuming it is used as a parameter to methods that take uints).
Noah Richards
https://connect.microsoft.com/VisualStudio/feedback/details/574068/-vsfindresult-vsfr-andreplace-has-an-incorrect-value
Adam Driscoll