【发布时间】:2011-03-04 09:26:28
【问题描述】:
我使用的是 Visual Studio 2003。在调试模式下,每当我在我的 javascript (js) 文件中添加断点时,该文件就会被锁定,因此无法编辑。
关闭选项卡并重新打开它似乎可以解锁它。
我想知道的是:为什么会发生这种情况,是否有某种设置可以防止这种情况发生?
【问题讨论】:
标签: javascript visual-studio-2003
我使用的是 Visual Studio 2003。在调试模式下,每当我在我的 javascript (js) 文件中添加断点时,该文件就会被锁定,因此无法编辑。
关闭选项卡并重新打开它似乎可以解锁它。
我想知道的是:为什么会发生这种情况,是否有某种设置可以防止这种情况发生?
【问题讨论】:
标签: javascript visual-studio-2003
我认为这是设计使然。当您遇到断点时,Visual Studio 会显示实际文件的副本。调试期间不能编辑。
【讨论】:
发现这个宏会自动关闭并重新打开你所在的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
【讨论】: