Skip to content

Commit 0774e41

Browse files
Fix edge cases and lint warnings
1 parent 0f34bc9 commit 0774e41

File tree

3 files changed

+20
-23
lines changed

3 files changed

+20
-23
lines changed

CodeEdit/Features/LSP/Service/LSPService.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ final class LSPService: ObservableObject {
334334
extension LSPService {
335335
private func notifyToInstallLanguageServer(language lspLanguage: LanguageIdentifier) {
336336
// TODO: Re-Enable when this is more fleshed out (don't send duplicate notifications in a session)
337-
return
337+
#if false
338338
let lspLanguageTitle = lspLanguage.rawValue.capitalized
339339
let notificationTitle = "Install \(lspLanguageTitle) Language Server"
340340
// Make sure the user doesn't have the same existing notification
@@ -354,6 +354,7 @@ extension LSPService {
354354
// This will always read the default value and will not update
355355
self?.openWindow(sceneID: .settings)
356356
}
357+
#endif
357358
}
358359
}
359360

CodeEdit/Features/NavigatorArea/ProjectNavigator/OutlineView/ProjectNavigatorOutlineView.swift

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,13 @@ struct ProjectNavigatorOutlineView: NSViewControllerRepresentable {
9393
if outlineView.window?.firstResponder !== outlineView
9494
&& outlineView.window?.firstResponder is NSTextView
9595
&& (outlineView.window?.firstResponder as? NSView)?.isDescendant(of: outlineView) == true {
96-
// Find the cell being edited by traversing up from the text view
97-
var currentView = outlineView.window?.firstResponder as? NSView
9896
capturedSelectionRange = (outlineView.window?.firstResponder as? NSTextView)?.selectedRange
9997

98+
// Find the cell being edited by traversing up from the text view
99+
var currentView = outlineView.window?.firstResponder as? NSView
100100
while let view = currentView {
101101
if let cell = view as? ProjectNavigatorTableViewCell,
102-
let fileItem = cell.fileItem,
103-
fileItem.phantomFile != nil {
102+
let fileItem = cell.fileItem, fileItem.phantomFile != nil {
104103
editingPhantomFile = fileItem
105104
capturedText = cell.textField?.stringValue
106105
break
@@ -114,33 +113,32 @@ struct ProjectNavigatorOutlineView: NSViewControllerRepresentable {
114113
outlineView.reloadItem(item, reloadChildren: true)
115114
}
116115

116+
// Restore selected items where the files still exist.
117+
let selectedIndexes = selectedRows.compactMap({ outlineView.row(forItem: $0) }).filter({ $0 >= 0 })
118+
controller?.shouldSendSelectionUpdate = false
119+
outlineView.selectRowIndexes(IndexSet(selectedIndexes), byExtendingSelection: false)
120+
controller?.shouldSendSelectionUpdate = true
121+
117122
// If we were editing a phantom file, restore the text field and focus
118123
if let phantomFile = editingPhantomFile, let text = capturedText {
119124
let row = outlineView.row(forItem: phantomFile)
120-
if row >= 0,
121-
let cell = outlineView.view(
125+
if row >= 0, let cell = outlineView.view(
122126
atColumn: 0,
123127
row: row,
124128
makeIfNecessary: false
125-
) as? ProjectNavigatorTableViewCell {
129+
) as? ProjectNavigatorTableViewCell {
126130
cell.textField?.stringValue = text
127131
outlineView.window?.makeFirstResponder(cell.textField)
128132
if let selectionRange = capturedSelectionRange {
129133
cell.textField?.currentEditor()?.selectedRange = selectionRange
130134
}
131135
}
132-
}
133-
134-
// Restore selected items where the files still exist.
135-
let selectedIndexes = selectedRows.compactMap({ outlineView.row(forItem: $0) }).filter({ $0 >= 0 })
136-
controller?.shouldSendSelectionUpdate = false
137-
outlineView.selectRowIndexes(IndexSet(selectedIndexes), byExtendingSelection: false)
138-
controller?.shouldSendSelectionUpdate = true
139-
140-
// Reselect the file that is currently active in the editor so it still appears highlighted
141-
if outlineView.selectedRowIndexes.isEmpty,
142-
let activeFileID = workspace?.editorManager?.activeEditor.selectedTab?.file.id {
143-
controller?.updateSelection(itemID: activeFileID)
136+
} else {
137+
// Reselect the file that is currently active in the editor so it still appears highlighted
138+
if selectedIndexes.isEmpty,
139+
let activeFileID = workspace?.editorManager?.activeEditor.selectedTab?.file.id {
140+
controller?.updateSelection(itemID: activeFileID)
141+
}
144142
}
145143
}
146144

CodeEdit/Features/NavigatorArea/ProjectNavigator/OutlineView/ProjectNavigatorViewController+OutlineTableViewCellDelegate.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,5 @@ extension ProjectNavigatorViewController: OutlineTableViewCellDelegate {
4040
}
4141
}
4242

43-
func cellDidFinishEditing() {
44-
outlineView.reloadData()
45-
}
43+
func cellDidFinishEditing() { }
4644
}

0 commit comments

Comments
 (0)