开发者

Javascript file locked when breakpoint added

开发者 https://www.devze.com 2023-02-14 15:12 出处:网络
I\'m using Visual Studio 2003. In debug mode, whenever I add a break point in my javascript (js) file, the file then beco开发者_StackOverflow社区mes locked so that it can\'t be edited.

I'm using Visual Studio 2003. In debug mode, whenever I add a break point in my javascript (js) file, the file then beco开发者_StackOverflow社区mes locked so that it can't be edited.

Closing the tab and reopening it seems to unlock it.

What I'd like to know is: why does this happen and is there some kind of setting that would prevent this from happening?


I think this is by design. When you hit a breakpoint Visual Studio shows a copy of the actual file. You cannot edit it during debugging.


Found this macro which automatically closes and reopens the js page you are on, and moves the cursor back to the line you are on. Hope it comes in useful to someone.

Imports EnvDTE
Imports System.Diagnostics

Public Module AllowJSModify

    Sub ReOpenWindow()
        Try
            'get line no
            Dim objCursorTxtPoint As EnvDTE.TextPoint = GetCursorTxtPnt()
            Dim intLine As Integer = objCursorTxtPoint.Line

            'get current filename
            Dim strActiveWindow = DTE.ActiveWindow.Document.FullName

            'close open file (auto-save)
            DTE.ActiveWindow.Close(vsSaveChanges.vsSaveChangesYes)

            're-open file
            Dim item As EnvDTE.ProjectItem = DTE.Solution.FindProjectItem(strActiveWindow)
            item.Open()
            item.Document.Activate()

            'go to prev line no
            DTE.ActiveDocument.Selection.GotoLine(intLine)
        Catch ex As System.Exception
            MsgBox("You are not focused on a line of code.", MsgBoxStyle.Critical, "Error")
        End Try
    End Sub

    Private Function GetCursorTxtPnt() As EnvDTE.TextPoint

        Dim objTextDocument As EnvDTE.TextDocument

        Dim objCursorTxtPoint As EnvDTE.TextPoint

        Try

            objTextDocument = CType(DTE.ActiveDocument.Object, EnvDTE.TextDocument)

            objCursorTxtPoint = objTextDocument.Selection.ActivePoint()

        Catch ex As System.Exception

        End Try

        Return objCursorTxtPoint

    End Function

End Module
0

精彩评论

暂无评论...
验证码 换一张
取 消