【问题标题】:Javascript file locked when breakpoint added添加断点时 Javascript 文件被锁定
【发布时间】:2011-03-04 09:26:28
【问题描述】:

我使用的是 Visual Studio 2003。在调试模式下,每当我在我的 javascript (js) 文件中添加断点时,该文件就会被锁定,因此无法编辑。

关闭选项卡并重新打开它似乎可以解锁它。

我想知道的是:为什么会发生这种情况,是否有某种设置可以防止这种情况发生?

【问题讨论】:

    标签: javascript visual-studio-2003


    【解决方案1】:

    我认为这是设计使然。当您遇到断点时,Visual Studio 会显示实际文件的副本。调试期间不能编辑。

    【讨论】:

    • 那么愚蠢的设计。谢谢比尔盖茨:-)
    • 它可能不是那么愚蠢,因为一旦你修改了一个 JavaScript 文件,就没有办法告诉浏览器重新加载它。您需要重新加载页面才能做到这一点。
    • 是的。但是在浏览器上重新加载页面很容易。为什么不让用户在知道刷新页面后才生效的情况下编辑 js 文件。无论如何,从 2005 年开始,一切都变了。
    【解决方案2】:

    发现这个宏会自动关闭并重新打开你所在的js页面,并将光标移回你所在的行。希望它对某人有用。

    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-13
      • 2015-12-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-22
      • 1970-01-01
      相关资源
      最近更新 更多